I have a partial class like this
public partial class ABC
{
public string GetName()
{
//some code here
}
public string GetAge()
{
//some code here
}
}
public partial class ABC
{
public string GetSex()
{
//some code here
}
public string GetAge()
{
//some code here
}
}
How these 2 class merge at build time? Please give me explanation about it.
There will be a compile time error when you try to compile this code!
What happens at build time is the compiler
combines all the members defined in all the partial definitions of the class into one. It will then try to compile it the usual way.
In your case it will raise an error mentioning you already have defined a method with the same name.
It doesn't compile as you can't have two methods with the same name in one class.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With