Assert Is Object Not Null - CSharp Microsoft.VisualStudio.TestTools.UnitTesting

CSharp examples for Microsoft.VisualStudio.TestTools.UnitTesting:Assert

Description

Assert Is Object Not Null

Demo Code


using System.Threading.Tasks;
using System.Text;
using System.Linq;
using System.Collections.Generic;
using System;/*from  w  w w  .j  a  va  2s.c  o m*/

public class Main{
        public static void NotNull(object o, string name)
        {
            if (o == null)
            {
                name = name ?? "argument";
                throw new ArgumentNullException(String.Format("{0} cannot be null", name));
            }
        }
}

Related Tutorials