I have a situation when calling a constructor with a lot of parameters.
In the following code, I create a System.Data.Dat aTable instance.
I run this code step by step in debug mode and I have lpDataTable.Row s in
the Watch window.
The problem is that in the watch window, lpDataTable.Row s display "error:
cannot obtain value" instead of "{System.Data.D ataRowCollectio n}".
This happen only when I call the Class2 constructor with 33 string
parameters. Calling it with 32 parameters will not cause this.
lpClass2 = new
Class2("","","" ,"","","","","" ,"","","","","" ,"","","","","" ,"","","","","" ,
"","","","","", "","","","","") ; is placed after lpDataTable = new
DataTable();
but it's presence is enought to cause lpDataTable.Row s to display "error:
cannot obtain value" in the watch window.
To reproduce that behavior, copy/paste the following code as a new c#
console project and add lpDataTable.Row s as a debug watch.
You will see lpDataTable.Row s "error: cannot obtain value"
Then call the Class2 Constructor with 32 parameters instead of 33, and it
works well.
What's going on there?
Thank
using System;
using System.Data;
namespace CrazyProject
{
class Class1
{
static void Main(string[] args)
{
Class2 lpClass2;
DataTable lpDataTable;
lpDataTable = new DataTable();
//32 string parameters
lpClass2 = new
Class2("","","" ,"","","","","" ,"","","","","" ,"","","","","" ,"","","","","" ,
"","","","","", "","","","","") ;
}
}
class Class2
{
public Class2(string p000,string p001,string p002,string p003,string
p004,string p005,string p006,string p007,string p008,string p009,string
p010,string p011,string p012,string p013,string p014,string p015,string
p016,string p017,string p018,string p019,string p020,string p021,string
p022,string p023,string p024,string p025,string p026,string p027,string
p028,string p029,string p030,string p031){}
public Class2(string p000,string p001,string p002,string p003,string
p004,string p005,string p006,string p007,string p008,string p009,string
p010,string p011,string p012,string p013,string p014,string p015,string
p016,string p017,string p018,string p019,string p020,string p021,string
p022,string p023,string p024,string p025,string p026,string p027,string
p028,string p029,string p030,string p031,string p032){}
}
}
David Laplante
dl*******@cimte ch.ca