in the code you pasted here, you are making the declaration of an object of class but initialization is missing.
if you use any object without initialization, you will get object reference exception.
for your case you need to initialize your class object by calling a contructor of your class with New keyword.
i.e
MyClass obj = new MyClass()
here MyClass() is the 0 argument constructor of your class, you can find it inside your code behind file or designer.