Hi, i was wondering,
in C# the ListNode val is defaulted to 0,
but you are expected to create a listnode without a value ([] + [] = []), is this a bug?
the default would be [0]+[0] = [00]
this is the current class description i get:
public class ListNode {
public int val;
public ListNode next;
// class gets defaulted to 0 here
public ListNode(int val=0, ListNode next=null) {
this.val = val;
this.next = next;
}
}Also an integer is a non-nullable value, so it isn't possible to assign this to null. neither can you bypass the object constructor using activator if you'll get an error that a non-parameterless constructor doesnt exist:
Unhandled exception. System.MissingMethodException: No parameterless constructor defined for type 'Test.Problems.BaseTypes.ListNode'.
at System.RuntimeType.CreateInstanceDefaultCtorSlow(Boolean publicOnly, Boolean wrapExceptions, Boolean fillCache)
at System.RuntimeType.CreateInstanceDefaultCtor(Boolean publicOnly, Boolean skipCheckThis, Boolean fillCache, Boolean wrapExceptions)
at System.Activator.CreateInstance(Type type, Boolean nonPublic, Boolean wrapExceptions)
at System.Activator.CreateInstance(Type type)
at Leetcode.Problems.MergeTwoSortedLists_.RunTest() in Z:\C#\Leetcode\Test\Problems\0021MergeTwoSortedLists.cs:line 53
at Leetcode.Program.RenderMenu() in Z:\C#\Leetcode\Test\Program.cs:line 57
at Leetcode.Program.Main(String[] args) in Z:\C#\Leetcode\Test\Program.cs:line 27