I've stumbed across this class in an existing code base:
[Serializable]
public class PillowFight
{
public PillowFight(object providedObject);
public object providedObject { get; }
public Dictionary<string, PillowData> Properties { get; }
public PillowData GetPillowByName(string pillowName);
public void SetPillowValue(string pillowName, object value);
}
I would not have expected this to compile because of the missing implementations on the constructor, GetPillowByName and SetPillowValue since it's not abstract or an interface. This is valid? Why would one do this and what's the advantage?
No, it is not valid. Probably you have seen this when using the 'go to definition (F12)' function in Visual Studio. If the source is in another assembly, it will only show the outline, not the actual code.
See the corresponding dotnetfiddle (which doesn't compile).
Error:
PillowFight.PillowFight(object)' must declare a body because it is not marked abstract, extern, or partial
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