cast object[] as Type[] ?
-
Hi, i'm trying to write a function where i can do this:
private bool ParameterCheck(Type[] expected, object[] actual)
{
if (actual.Length != expected.Length)
return false;for (int i = 0; i < actual.Length; i++) { if(actual\[i\] as expected\[i\] == null) //vs won't let me do this return false; } return true; }
The goal is to check if a object array is the same length and same type as some expected parameters.
-
Hi, i'm trying to write a function where i can do this:
private bool ParameterCheck(Type[] expected, object[] actual)
{
if (actual.Length != expected.Length)
return false;for (int i = 0; i < actual.Length; i++) { if(actual\[i\] as expected\[i\] == null) //vs won't let me do this return false; } return true; }
The goal is to check if a object array is the same length and same type as some expected parameters.
FocusedWolf wrote:
if(actual[i] as expected[i] == null)
if (actual[i].GetType() != expected[i])
Life, family, faith: Give me a visit. From my latest post: "How differently the psalmist saw it! How blessed -- how truly happy with real joy! -- is the man who delights in the Law of the Lord." Judah Himango
-
FocusedWolf wrote:
if(actual[i] as expected[i] == null)
if (actual[i].GetType() != expected[i])
Life, family, faith: Give me a visit. From my latest post: "How differently the psalmist saw it! How blessed -- how truly happy with real joy! -- is the man who delights in the Law of the Lord." Judah Himango
-
Hi, i'm trying to write a function where i can do this:
private bool ParameterCheck(Type[] expected, object[] actual)
{
if (actual.Length != expected.Length)
return false;for (int i = 0; i < actual.Length; i++) { if(actual\[i\] as expected\[i\] == null) //vs won't let me do this return false; } return true; }
The goal is to check if a object array is the same length and same type as some expected parameters.
-
Hi, i'm trying to write a function where i can do this:
private bool ParameterCheck(Type[] expected, object[] actual)
{
if (actual.Length != expected.Length)
return false;for (int i = 0; i < actual.Length; i++) { if(actual\[i\] as expected\[i\] == null) //vs won't let me do this return false; } return true; }
The goal is to check if a object array is the same length and same type as some expected parameters.
Brilliance. You would have thought that runtime would let you call the method and catch the exception :) (no language in the world should allow for that scenario)
-
Oops, wrong answer, see mine :)
xacc.ide - now with TabsToSpaces support
IronScheme - 1.0 alpha 4a out now (29 May 2008)I see them both wrong, see another one :)
-
I see them both wrong, see another one :)
-
Oops, wrong answer, see mine :)
xacc.ide - now with TabsToSpaces support
IronScheme - 1.0 alpha 4a out now (29 May 2008)Bah, well, I made his code compile, didn't fix his problems. Call me an ugly patcher. ;)
Life, family, faith: Give me a visit. From my latest post: "How differently the psalmist saw it! How blessed -- how truly happy with real joy! -- is the man who delights in the Law of the Lord." Judah Himango