关于在MVC中view中设置默认值,可以象如下设置:
1、关于ViewModel的部分
如果是C# 6.0
1 public class Test 2 { 3 public int A { get; set; } = 1; 4 public string B { get; set; } = "Test"; 5 }
如果语法不支持,只能改回.net 2.0的写法。
1 public class UserType 2 { 3 private int _usertypeid = 1; 4 public int USERTYPEID 5 { 6 get 7 { 8 return this._usertypeid; 9 } 10 set 11 { 12 this._usertypeid = value; 13 } 14 } 15 }
转自:https://blog.csdn.net/qq_39569480/article/details/104651722
标签:实体类,get,C#,int,set,默认值,public From: https://www.cnblogs.com/guangfangxiaokeai/p/17384404.html