如何使用类在C#中全局声明 [英] how to declare globally in C# using a class
本文介绍了如何使用类在C#中全局声明的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
public class myCommon
{
public static sqlConnection = new csSQL = sqlConnection("myconnectionString)";
}
您的消耗代码看起来像:
and your consuming code would look somthing like:
private void frmDemo_Load(object sender, EventArgs e)
{
this.Text = myCommon.csSQL;
}
推荐答案
这是您的问题的解决方案
This is the solution of your problem
public static class myCommon
{
public static sqlConnection = new csSQL = sqlConnection("myconnectionString)";
}
创建一个静态类
Tanvtech
Create a static class
Tanvtech
这篇关于如何使用类在C#中全局声明的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文