Say I have this object:
dynamic foo = new ExpandoObject(); foo.bar = "fizz"; foo.bang = "buzz";
How would I remove foo.bang
for example?
I don't want to simply set the property's value to null--for my purposes I need to remove it altogether. Also, I realize that I could create a whole new ExpandoObject by drawing kv pairs from the first, but that would be pretty inefficient.
The not-equal-to operator ( != ) returns true if the operands don't have the same value; otherwise, it returns false .
In mathematics, the tilde often represents approximation, especially when used in duplicate, and is sometimes called the "equivalency sign." In regular expressions, the tilde is used as an operator in pattern matching, and in C programming, it is used as a bitwise operator representing a unary negation (i.e., "bitwise ...
An operator is a symbol that tells the compiler to perform specific mathematical or logical functions. C language is rich in built-in operators and provides the following types of operators − Arithmetic Operators.
In C/C++, the # sign marks preprocessor directives. If you're not familiar with the preprocessor, it works as part of the compilation process, handling includes, macros, and more.
Cast the expando to IDictionary<string, object>
and call Remove
:
var dict = (IDictionary<string, object>)foo; dict.Remove("bang");
You can treat the ExpandoObject
as an IDictionary<string, object>
instead, and then remove it that way:
IDictionary<string, object> map = foo; map.Remove("Jar");
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With