Fast ArgumentNullException with attributes. It is possible?

Posted by Fraga on Stack Overflow See other posts from Stack Overflow or by Fraga
Published on 2010-05-17T03:28:08Z Indexed on 2010/05/17 3:30 UTC
Read the original article Hit count: 319

Hi.

Is there any fast way to verify null arguments via attributes or something?

Convert this:

public void Method(type arg1,type arg2,type arg3)
{
     if (arg1== null) throw new ArgumentNullException("arg1");
     if (arg2== null) throw new ArgumentNullException("arg2");
     if (arg3== null) throw new ArgumentNullException("arg3");
     //Business Logic
}

Into something like this:

[VerifyNullArgument("arg1","arg2","arg3")]
public void Method(type arg1,type arg2,type arg3)
{
      //Business Logic
}

Ideas? thanks guys.

© Stack Overflow or respective owner

Related posts about attributes

Related posts about argumentnullexception