Parse()
Can I override the parse method for my class?it doesn't belong to the object class?so how can I do that?
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Roei BarPosted Oct 18, 2009, 7:38 AM
static string Parse(string info)
this will override the default Parse
Kirtan PatelPosted Oct 18, 2009, 9:08 AM
namespace WindowsFormsApplication4
{
class ClassA
{
public virtual string parse(string s)
{
return s;
}
}
class ClassB:ClassA
{
public override string parse(string s)
{
return "Override Method";
}
}
}
Answer to First Question
------------------------
parse method is not available in object class or String Class
its only available into wrapper classes like Int , Float,Double etc...
Explaination about Overriding Parse()
-------------------------------------
Here we have Two Class ClassA and ClassB
ClassA Having method parse() now we want to oveer ride it so we have to declare it as abstract or as virtual to be override into another class ClassB .
Now ClassB will Inherit ClassA
now declare method parse again with the same signature .A signature mean method's structure will be same as parse() method in ClassA
so write method Parse() in ClassB with keyword ovverride :)
now when you make Intance of class b the ovverridern method will be called instead of ClassA's Parse method
thats it
you are done :)
Friend,if still having any questions let me know :)
Happy Coding :)