What is the difference between String and string in C#?

string is an alias in C# for System.String.So technically, there is no difference. It’s like int vs. System.Int32. As far as guidelines, it’s generally recommended to use string any time you’re referring to an object. e.g. Likewise, I think it’s generally recommended to use String if you need to refer specifically to the class. e.g. This is the style that Microsoft tends to use … Read more

What is a `char*`?

It is a pointer to a char. When declaring a pointer, the asterisk goes after the type and before the identifier, with whitespace being insignificant. These all declare char pointers: To make things even more confusing, when declaring multiple variables at once, the asterisk only applies to a single identifier (on its right). E.g.: It is primarily for … Read more

Type Checking: typeof, GetType, or is?

All are different. typeof takes a type name (which you specify at compile time). GetType gets the runtime type of an instance. is returns true if an instance is in the inheritance tree. Example What about typeof(T)? Is it also resolved at compile time? Yes. T is always what the type of the expression is. … Read more

How to create a new object instance from a Type

The Activator class within the root System namespace is pretty powerful. There are a lot of overloads for passing parameters to the constructor and such. Check out the documentation at: http://msdn.microsoft.com/en-us/library/system.activator.createinstance.aspx or (new path) https://docs.microsoft.com/en-us/dotnet/api/system.activator.createinstance Here are some simple examples:

Finding the type of an object in C++

dynamic_cast should do the trick The dynamic_cast keyword casts a datum from one pointer or reference type to another, performing a runtime check to ensure the validity of the cast. If you attempt to cast to pointer to a type that is not a type of actual object, the result of the cast will be … Read more

What is the meaning of id?

id is a pointer to any type, but unlike void * it always points to an Objective-C object. For example, you can add anything of type id to an NSArray, but those objects must respond to retain and release. The compiler is totally happy for you to implicitly cast any object to id, and for you to cast id to any object. This is unlike any … Read more