M
Mark S.
Hello Group,
This line of c# dot net 2.0 code:
MyStruct thisAd = (MyStruct)myArray.GetValue(i);
Generates this error.
mscorlib
at System.TypedReference.InternalToObject(Void* value)
at System.Array.GetValue(Int32 index)
I am unable to reproduce in my test environement. I would really appreciate
your thoughts.
The line of code in question is a big block of code, so I've distilled it
down to it's essence. Unless necessary please refrain from asking "why you
did something this way". I'm still learning how to code with best practices,
so if there's a better way please describe and I'll be happy to learn it.
using System;
namespace ConsoleForTesting
{
[Serializable()]
public struct MyStruct
{
public string str1;
public string str2;
public int int1;
public int int2;
public int int3;
public string string3;
public int int4;
public int int5;
public int int6;
public int int7;
public Array array1;
public int int8;
public int int9;
}
class test
{
static void Main(string[] args)
{
MyStruct[] myArray = new MyStruct[1];
MyStruct myStruct = new MyStruct();
myArray[0] = myStruct;
// there are numerous loops like this one in the same method
for (int i = 0; i < myArray.Length; i++)
{
MyStruct thisAd = (MyStruct)myArray.GetValue(i);
// when I put in 1 it generates the expected "Index was
outside the bounds of the array.",
// but not the mscorlib at
System.TypedReference.InternalToObject(Void* value)at
System.Array.GetValue(Int32 index)
}
Console.WriteLine("Press any key to exit.");
Console.ReadLine();
}
}
}
This line of c# dot net 2.0 code:
MyStruct thisAd = (MyStruct)myArray.GetValue(i);
Generates this error.
mscorlib
at System.TypedReference.InternalToObject(Void* value)
at System.Array.GetValue(Int32 index)
I am unable to reproduce in my test environement. I would really appreciate
your thoughts.
The line of code in question is a big block of code, so I've distilled it
down to it's essence. Unless necessary please refrain from asking "why you
did something this way". I'm still learning how to code with best practices,
so if there's a better way please describe and I'll be happy to learn it.
using System;
namespace ConsoleForTesting
{
[Serializable()]
public struct MyStruct
{
public string str1;
public string str2;
public int int1;
public int int2;
public int int3;
public string string3;
public int int4;
public int int5;
public int int6;
public int int7;
public Array array1;
public int int8;
public int int9;
}
class test
{
static void Main(string[] args)
{
MyStruct[] myArray = new MyStruct[1];
MyStruct myStruct = new MyStruct();
myArray[0] = myStruct;
// there are numerous loops like this one in the same method
for (int i = 0; i < myArray.Length; i++)
{
MyStruct thisAd = (MyStruct)myArray.GetValue(i);
// when I put in 1 it generates the expected "Index was
outside the bounds of the array.",
// but not the mscorlib at
System.TypedReference.InternalToObject(Void* value)at
System.Array.GetValue(Int32 index)
}
Console.WriteLine("Press any key to exit.");
Console.ReadLine();
}
}
}