社区
C#
帖子详情
属性简写时默认值该如何写,如:public string test{get;set}
aspnet30
2009-11-13 05:17:23
属性简写时默认值该如何写,如:public string test{get;set}
test的默认值该怎么写?
...全文
2082
7
打赏
收藏
属性简写时默认值该如何写,如:public string test{get;set}
属性简写时默认值该如何写,如:public string test{get;set} test的默认值该怎么写?
复制链接
扫一扫
分享
转发到动态
举报
写回复
配置赞助广告
用AI写文章
7 条
回复
切换为时间正序
请发表友善的回复…
发表回复
打赏红包
wjw6200
2009-11-13
打赏
举报
回复
public string test {
get
{
if (test == null)
{
return "默认值";
}
else
{
return test;
}
}
set { test = value; }
}
Get 的时候判断一下就可以了。
gomoku
2009-11-13
打赏
举报
回复
[Quote=引用 4 楼 zhujiazhi 的回复:]
构造函数里写
[/Quote]
简写就是简写。如果你要更多的控制,就不用简写。
RexZheng
2009-11-13
打赏
举报
回复
好像是没办法的
zhujiazhi
2009-11-13
打赏
举报
回复
构造函数里写
aspnet30
2009-11-13
打赏
举报
回复
我想用public string test{get;set;}的时候,能为这个属性赋默认值
PandaIT
2009-11-13
打赏
举报
回复
prop 按Tab键
你想干嘛?
public string test{get;set;}
whslovexyp
2009-11-13
打赏
举报
回复
get的时候需要return
private string m_test = string.Empty;
public string test{get return m_test;}
HTML5网页设计和制作(1-4):语义标签/智能表单/标签自定义
属性
HTML5 是定义 HTML 标准的最新的版本。它是一个新版本的HTML语言,具有新的元素,
属性
和行为;它有更大的技术集,允许构建更多样化和更强大的网站和应用程序。这个集合有
时
称为HTML5和它的朋友们,不过大多数
时
候仅缩
写
为一个词 HTML5。
c# 3.0 get
set
默认值
之前曾经介绍过 C# 3.0 { get;
set
; }
默认值
,本文是在其基础上完成的,增加了些内容。 .NET Framework 3.5 使用的是 C# 3.0,C# 3.0 有一些新的语言特性,其中有一项就是快捷
属性
。 之前的
写
法: private int _id = 0;
public
int Id { get { return _id; }
Type Script
属性
封装(
public
、private、protected)
文章目录`
public
``private`js使用getter和
set
ter的方法:TS中get和
set
语法糖:`protected`
简
写
方法:
public
TS可以在
属性
前添加
属性
的修饰符
public
修饰的
属性
可以在任意位置访问(修改)
默认值
(function () { //定义一个表示人物的类 class Person { name:
string
; //可以加也可以不加
public
age: number; constructor(name: strin
TS的相关知识
ts
写
法 interface Iprop { func1: () =>
string
; // 函数返回一个
string
; func2: (a:
string
, b: number) => void; // 函数输入两个参数,没有返回值; str1:
string
; // str1参数必须是字符串;
Creator与Laya的Ts和JsTS的版
属性
声明详解,
属性
详解,Enum枚举,dataSource组件综合赋值,box容器复杂赋值[子对象的
属性
名的geChildByName],clip切片动画
//0—)TS中实现构造函数 // class person{ // name:
string
;//
属性
// constructor(n:
string
) // { // this.name=n; // } // run():void { // alert(this.name); // } // } // var p=n...
C#
110,533
社区成员
642,574
社区内容
发帖
与我相关
我的任务
C#
.NET技术 C#
复制链接
扫一扫
分享
社区描述
.NET技术 C#
社区管理员
加入社区
获取链接或二维码
近7日
近30日
至今
加载中
查看更多榜单
社区公告
让您成为最强悍的C#开发者
试试用AI创作助手写篇文章吧
+ 用AI写文章