How can we identify partial classes in C#?

 Posted by Loganathanav on 11/7/2014 | Category: C# Interview questions | Views: 611 | Points: 40
Answer:

The class declaration with the keyword partial is denoting that the class is a partial class. Physically the partial classes can be available in different files/locations. The C# compiler treat them as a single class at the time of compilation.


public partial class PartialClassExample
{
public void MethodOne(int input)
{
///Do something.
}
}

public partial class PartialClassExample
{
public string MethodTwo(string input)
{
return string.Format("Hello, {0}", input);
}
}


The PartialClassExample can be sit in different files but at the time of compilation they will be merged together.

Hope this helps!


Asked In: Many Interviews | Alert Moderator 

Comments or Responses

Login to post response

More Interview Questions by Loganathanav