i have a windows form and a class named testclass.cs . the below sample code is for testclass.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace testApp
{
public class testclass
{
public void disableEverything()
{
//some operations goes here
}
public void welcome()
{
//some code goes here
}
}
}
and inside my form i have code for create object inside a button click event the below code shows the form1
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace testApp
{
public partial class Form1: Form
{
private void button1_Click(object sender, EventArgs e)
{
testclass obj = new testclass();
obj.welcome();
}
}
}
my question is if i click button1 five times it will create 5 objects of the class testclass
.
suppose if i want to call disableEverything
method of some purticular class objects like 3rd object, second object , how can i call this? should i use a List<testclass>
and call list[index].disableEverything()
. suggest me a good soultion for this