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.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Roei BarRank #1,271 · 1.4K reputationPosted Oct 18, 2009, 3:38 AM EDT
static string Parse(string info)
this will override the default Parse
Kirtan PatelRank #292 · 8.6K reputationPosted Oct 18, 2009, 5:08 AM EDT
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 :)