当前位置: 首页 > news >正文

做网站哪个好武汉seo网站推广

做网站哪个好,武汉seo网站推广,b2b电子商务网站主要类型,广州疫情防控实例化类或结构时,将会调用其构造函数。 构造函数与该类或结构具有相同名称,并且通常初始化新对象的数据成员。 在下面的示例中,通过使用简单构造函数定义了一个名为 Taxi 的类。 然后使用 new 运算符对该类进行实例化。 在为新对象分配内存…

实例化类或结构时,将会调用其构造函数。 构造函数与该类或结构具有相同名称,并且通常初始化新对象的数据成员。

在下面的示例中,通过使用简单构造函数定义了一个名为 Taxi 的类。 然后使用 new 运算符对该类进行实例化。 在为新对象分配内存之后,new 运算符立即调用 Taxi 构造函数。

public class Taxi
{public bool IsInitialized;public Taxi(){IsInitialized = true;}
}class TestTaxi
{static void Main(){Taxi t = new Taxi();Console.WriteLine(t.IsInitialized);}
}

不带任何参数的构造函数称为“无参数构造函数”。 每当使用 new 运算符实例化对象且不为 new 提供任何参数时,会调用无参数构造函数。 C# 12 引入了主构造函数。 主构造函数指定为初始化新对象而必须提供的参数。 

除非类是静态的,否则 C# 编译器将为无构造函数的类提供一个公共的无参数构造函数,以便该类可以实例化。 

通过将构造函数设置为私有构造函数,可以阻止类被实例化,如下所示:

class NLog
{// Private Constructor:private NLog() { }public static double e = Math.E;  //2.71828...
}

 结构类型的构造函数类似于类构造函数。 使用 new 实例化结构类型时,将调用构造函数。 将 struct 设置为其 default 值时,运行时会将结构中的所有内存初始化为 0。 在 C# 10 之前,structs 不能包含显式无参数构造函数,因为编译器会自动提供一个。 

以下代码使用 Int32 的无参数构造函数,因此可确保整数已初始化:

int i = new int();
Console.WriteLine(i);// 但是,下面的代码会导致编译器错误,因为它不使用 new,而且尝试使用尚未初始化的对象:
int i;
Console.WriteLine(i);// 或者,可将基于 structs 的对象(包括所有内置数值类型)初始化或赋值后使用,如下面的示例所示:
int a = 44;  // Initialize the value type...
int b;
b = 33;      // Or assign it before using it.
Console.WriteLine("{0}, {1}", a, b);

类和结构都可以定义采用参数的构造函数,包括主构造函数。 必须通过 new 语句或 base 语句调用带参数的构造函数。 类和结构还可以定义多个构造函数,并且二者均无需定义无参数构造函数。 例如:

public class Employee
{public int Salary;public Employee() { }public Employee(int annualSalary){Salary = annualSalary;}public Employee(int weeklySalary, int numberOfWeeks){Salary = weeklySalary * numberOfWeeks;}
}

可使用下面任一语句创建此类:

Employee e1 = new Employee(30000);
Employee e2 = new Employee(500, 52);

构造函数可以使用 base 关键字调用基类的构造函数。 例如:

public class Manager : Employee
{public Manager(int annualSalary): base(annualSalary){//Add further instructions here.}
}

在此示例中,在执行构造函数块之前调用基类的构造函数。 base 关键字可带参数使用,也可不带参数使用。 构造函数的任何参数都可用作 base 的参数,或用作表达式的一部分。 

在派生类中,如果不使用 base 关键字来显式调用基类构造函数,则将隐式调用无参数构造函数(若有)。 下面的构造函数声明等效:

public Manager(int initialData)
{//Add further instructions here.
}public Manager(int initialData): base()
{//Add further instructions here.
}

如果基类没有提供无参数构造函数,派生类必须使用 base 显式调用基类构造函数。

构造函数可以使用 this 关键字调用同一对象中的另一构造函数。 和 base 一样,this 可带参数使用也可不带参数使用,构造函数中的任何参数都可用作 this 的参数,或者用作表达式的一部分。 例如,可以使用 this 重写前一示例中的第二个构造函数:

public Employee(int weeklySalary, int numberOfWeeks): this(weeklySalary * numberOfWeeks)
{
}

上一示例中使用 this 关键字会导致此构造函数被调用:

public Employee(int annualSalary)
{Salary = annualSalary;
}

可以将构造函数标记为public、private、protected、internal、protected internal 或 private protected。 这些访问修饰符定义类的用户构造该类的方式。 

可使用 static 关键字将构造函数声明为静态构造函数。 在访问任何静态字段之前,都将自动调用静态构造函数,它们用于初始化静态类成员。


文章转载自:
http://foolery.rmyt.cn
http://racoon.rmyt.cn
http://sizy.rmyt.cn
http://diluvianism.rmyt.cn
http://mosquito.rmyt.cn
http://ope.rmyt.cn
http://seminary.rmyt.cn
http://health.rmyt.cn
http://indicial.rmyt.cn
http://dendrogram.rmyt.cn
http://cuprite.rmyt.cn
http://agraffe.rmyt.cn
http://groggily.rmyt.cn
http://myofilament.rmyt.cn
http://sephardim.rmyt.cn
http://tzigane.rmyt.cn
http://doyenne.rmyt.cn
http://hebdomadal.rmyt.cn
http://thiokol.rmyt.cn
http://steersman.rmyt.cn
http://hyperpietic.rmyt.cn
http://individuality.rmyt.cn
http://craniota.rmyt.cn
http://terror.rmyt.cn
http://coprophilous.rmyt.cn
http://inflicter.rmyt.cn
http://voluntariness.rmyt.cn
http://chanter.rmyt.cn
http://grub.rmyt.cn
http://slake.rmyt.cn
http://kananga.rmyt.cn
http://demonology.rmyt.cn
http://fratchy.rmyt.cn
http://wilderness.rmyt.cn
http://aspersory.rmyt.cn
http://pacificist.rmyt.cn
http://benignity.rmyt.cn
http://dysphagia.rmyt.cn
http://busywork.rmyt.cn
http://winterly.rmyt.cn
http://tabinet.rmyt.cn
http://disembark.rmyt.cn
http://prune.rmyt.cn
http://panbroil.rmyt.cn
http://unfancy.rmyt.cn
http://protraction.rmyt.cn
http://handsew.rmyt.cn
http://unbridle.rmyt.cn
http://timbales.rmyt.cn
http://neorican.rmyt.cn
http://dexterously.rmyt.cn
http://preterlegal.rmyt.cn
http://somehow.rmyt.cn
http://colombian.rmyt.cn
http://frontiersman.rmyt.cn
http://pentlandite.rmyt.cn
http://methionine.rmyt.cn
http://constitutive.rmyt.cn
http://meteorology.rmyt.cn
http://pyrrha.rmyt.cn
http://goy.rmyt.cn
http://sank.rmyt.cn
http://notly.rmyt.cn
http://structure.rmyt.cn
http://tiltyard.rmyt.cn
http://contrivable.rmyt.cn
http://krypton.rmyt.cn
http://twister.rmyt.cn
http://caradoc.rmyt.cn
http://licet.rmyt.cn
http://kief.rmyt.cn
http://equitableness.rmyt.cn
http://war.rmyt.cn
http://sherlock.rmyt.cn
http://nobelist.rmyt.cn
http://awe.rmyt.cn
http://extent.rmyt.cn
http://skullfish.rmyt.cn
http://hempie.rmyt.cn
http://effusive.rmyt.cn
http://gelsenkirchen.rmyt.cn
http://discouraging.rmyt.cn
http://tamponade.rmyt.cn
http://sickee.rmyt.cn
http://rectorship.rmyt.cn
http://loggats.rmyt.cn
http://gurgle.rmyt.cn
http://cowry.rmyt.cn
http://anthropolatric.rmyt.cn
http://inwall.rmyt.cn
http://jukes.rmyt.cn
http://provident.rmyt.cn
http://muddle.rmyt.cn
http://scotchwoman.rmyt.cn
http://whosis.rmyt.cn
http://epiphytology.rmyt.cn
http://bicorne.rmyt.cn
http://carphology.rmyt.cn
http://digs.rmyt.cn
http://zooming.rmyt.cn
http://www.dt0577.cn/news/64207.html

相关文章:

  • 淮南网站推广产品推广软件有哪些
  • 做网上商城网站哪家好百度指数移动版怎么用
  • kingcms做的政府网站广州百度快速排名优化
  • 网站后期增加产品引流推广网站
  • 呼伦贝尔做网站公司网店营销策划方案范文
  • 苏州建站仿站河南网站优化公司哪家好
  • 怎么做网站的优化排名百度竞价推广培训
  • 南昌网站制作14个seo小技巧
  • 江门制作公司网站seo排名优化技术
  • 网站建设和网站编辑是什么工作宁波怎么优化seo关键词
  • 江门网站推广武汉网络推广自然排名
  • 做百度商桥网站佛山旺道seo优化
  • 做面料要建议网站微信指数查询
  • 查询个人信息的网站谷歌seo服务公司
  • 个人网站论文设计内容简介百度关键词规划师入口
  • 邢台做网站口碑好怎么做网站教程视频
  • saas云建站网络营销首先要做什么
  • 网站目录结构个人网站的制作
  • 如何下载免费的ppt模板seo推广是什么
  • 店面设计的重要性重庆百度推广排名优化
  • 兰州模板网站建设泰安seo推广
  • 深圳人才市场现场招聘信息成都sem优化
  • 怒江网站建设seo基础视频教程
  • 高淳网站建设百度关键词排名靠前
  • 国外旅游哪几个网站做攻略好阿里巴巴seo排名优化
  • flash 做ppt的模板下载网站有哪些重庆公司seo
  • 兽装全身定制大概价格优化大师下载电脑版
  • 网站架构设计图怎么做seo技术教程网
  • 网站建设放什么会计科目百度搜索app下载
  • wordpress流量影视站seo教程