Casting
-
looks like you need xml deserialization. That is, having an object represented as an xml string, deserialize it in the proper class. Is that the case?
Best regards, Jaime.
No I have string and want to cast it to (color,point,font,...)
-
Okay, and how does the string look like? E.g. Point(10,20)? I guess you have to write your own method of converting the string to an object.
It's not a bug, it's a feature! Check out my CodeProject article Permission-by-aspect. Me in Softwareland.
no it looks like 10,20 for font : Arial for location : 15,19
-
no it looks like 10,20 for font : Arial for location : 15,19
And where does the data come from? I mean it could be very difficult to build an algorithm analysing the string itself it is a location or a font name or a color. This could end up in writing a compiler...
It's not a bug, it's a feature! Check out my CodeProject article Permission-by-aspect. Me in Softwareland.
-
how to convert (or Cast)
string
toC# classess
From what I read in the thread you're not really helpful in providing information. Note that we don't have any background on what you need to do or what you've done so far. Please elaborate a little on the problem. Where does the input come from? In what format is it set (XML, flat file, CSV,...)? Is there metadata included? What different types of 'classes' are we talking about? etc... If you want help you'll need to be more specific.
V.
-
No I have string and want to cast it to (color,point,font,...)
jojoba2010 wrote:
I have string and want to cast it to (color,point,font,...)
You cannot do this, a string is just a collection of characters. If you want to create some other object from it then you need to parse the string, extracting the relevant fields and create new objects based on that data. Read the documentation on what casting is, it does not convert one object to another.
MVP 2010 - are they mad?
-
how to convert (or Cast)
string
toC# classess
The word you are looking for is "parse". Many classes have a "Parse" method. For example:
int x = int.Parse("1");
To parse Point strings, you can use the
System.Drawing.PointConverter
class. For other classes, find the parse methods or create them yourself. -
I want to convert
string
to (Point,Font,Color,...
) ?jojoba2010 wrote:
Point
System.Drawing.PointConverter
jojoba2010 wrote:
Font
System.Drawing.FontConverter
jojoba2010 wrote:
Color
System.Drawing.ColorConverter
-
No I have string and want to cast it to (color,point,font,...)
what actuallly coming into your string!
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
Never mind - my own stupidity is the source of every "problem" - Mixturecheers, Alok Gupta VC Forum Q&A :- I/IV Support CRY- Child Relief and You
-
jojoba2010 wrote:
I have string and want to cast it to (color,point,font,...)
You cannot do this, a string is just a collection of characters. If you want to create some other object from it then you need to parse the string, extracting the relevant fields and create new objects based on that data. Read the documentation on what casting is, it does not convert one object to another.
MVP 2010 - are they mad?
Richard MacCutchan wrote:
MVP 2010 - are they mad?
Nope i don't think so!
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
Never mind - my own stupidity is the source of every "problem" - Mixturecheers, Alok Gupta VC Forum Q&A :- I/IV Support CRY- Child Relief and You
-
Richard MacCutchan wrote:
MVP 2010 - are they mad?
Nope i don't think so!
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
Never mind - my own stupidity is the source of every "problem" - Mixturecheers, Alok Gupta VC Forum Q&A :- I/IV Support CRY- Child Relief and You