Use a
Constructor
for the
class
.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace TstProject
{
class OneClass(int myVar)
{
int zz = myVar;
}
}
and in the
Form
:
private void frmMain_Load(object sender, EventArgs e)
{
OneClass oc = new OneClass(100);
}
But some marginal notes:
1. What is
myval
? It hasn't been defined.
2. You don't need to use a static variable for this case.
3. What is your plan for
zozo
?
4. your notation is not standard, for example:
frmMain
is in hungarian notation that you should not use.
myvar
(?!) what notation does it have? if it's a field or a variable use myVar (camelCasing) and if it's a propertym use MyVar (PascalCasing).
Please look at
C# Coding Standards - and Naming Conventions