Reputation: 407
I am currently trying to understand the purpose of partial methods as, the way in which i was hoping to use them was like an event.
Example.cs
public partial class Example
{
partial void LoadData();
public void Example()
{
LoadData();
}
public override void ToString() => (StringA + StringB);
}
Example.Hello.cs
public partial class Example
{
public string StringA;
partial void LoadData()
{
StringA = "HELLO";
}
}
Example.World.cs
public partial class Example
{
public string StringB;
partial void LoadData()
{
StringB = "WORLD";
}
}
public void Main
{
public void Main ()
{
Example ex = new Example();
Console.Write(ex.ToString());
}
}
Using the example pysudeo code above, I expect the Console to say "HELLOWORLD". This is how I originally thought partial methods should work, I believe I understand why it doesn't work this way, but I was hoping someone could help me come up with an alternative way of accomplishing this.
Essentially I only want to call one method and have that one method be able to lead all the data that I need for my Example.cs object.
TO BE CLEAR, i get that the application won't know how to order the function calls. but I honestly do not care for the order in my example. It could say "WORLDHELLO" for all i care.
Upvotes: 1
Views: 973