Google-sovellukset
Päävalikko

Post a Comment On: mo.notono.us

Untitled

2 Comments -

1 – 2 of 2
Anonymous Anonymous said...

If "subject is traget", you get a "true", but the loop does not stop.

So you get a "false" right after that.

This might work, because you get either "true" or "false", but never both.

public bool IsIn(object subject, params Type[] targetTypes)
{
foreach (Type target in targetTypes) {
if (subject is target)
return true;
else
return false;
}
}

Tuesday, November 16, 2004 1:26:00 PM

Blogger Oskar Austegard said...

Sorry - no, that will simply exit the loop after the first item.

I should have said - Why doesn't this compile?

There's nothing wrong with the loop construct - the issue has to do with the compiler barfing on the "subject is target" line - the is construct apparently can't be used with an instance of a type.

Tuesday, November 16, 2004 4:45:00 PM

You can use some HTML tags, such as <b>, <i>, <a>

Comments on this blog are restricted to team members.

You will be asked to sign in after submitting your comment.
Please prove you're not a robot