Hi,
Is there any way in c# that you can name custom objects on the fly?
I 'm trying to create a method which checks if a "Workload" object exists against a "User" object, and if not it creates one.
Hi,
Is there any way in c# that you can name custom objects on the fly?
I 'm trying to create a method which checks if a "Workload" object exists against a "User" object, and if not it creates one.
I'm not sure what you mean, but I think your looking for some kind of map/dictionary type of structure ?
C# has a collection class called NameValueCollection. It's similar to an STL map if thats what your looking for.
NameValueCollection Class (System.Collections.Specialized)
Not until C# 4.0 and "Dynamic objects" is released.
MagosX.com
Give a man a fish and you feed him for a day.
Teach a man to fish and you feed him for a lifetime.
You can also use a Dictionary<string, MyClass> (or, if you want objects of different types, Dictionary<string, object> ).
You ever try a pink golf ball, Wally? Why, the wind shear on a pink ball alone can take the head clean off a 90 pound midget at 300 yards.
can we define the variables in c sharp like this?i am looking through some codes here and while compiling got the error saying"are you missing a using directive or an assembly reference cs0246"Code:WeatherStation station, DateTime predictionDate
and it is showing error for this variables. I tried to remove it but the program have used the variable name station and predictionDate in the program. So can you help me out?
You can if you define them somewhere and add a semicolon instead of the comma.
Code:WeatherStation station; DateTime predictionDate;
Spidey out!