public class CalendarEvent
{ public int id { get; set; } public string title { get; set; } public string description { get; set; } [DefaultValue(typeof(DateTime), DateTime.Now.ToString("yyyy-MM-dd HH:mm"))]
public DateTime start { get; set; }
[DefaultValue(typeof(DateTime),DateTime.Now.ToString("yyyy-MM-dd HH:mm"))]
public DateTime end { get; set; }
[DefaultValue(typeof(bool), "false")]
public bool allDay { get; set; }
[DefaultValue(typeof(bool), "false")]
public bool overlap { get; set; }
[DefaultValue(typeof(string), "background-color")]
public string rendering { get; set; } //border-color,background-color
[DefaultValue(typeof(string), "#FFFFFF")]
public string color { get; set; } //
[DefaultValue(typeof(string), "#FFFFFF")]
public string backgroundColor { get; set; }
[DefaultValue(typeof(string), "#FFFFFF")]
public string textColor { get; set; }
[DefaultValue(typeof(string),"#FFFFFF")]
public string borderColor { get; set; }
[DefaultValue(typeof(int),"0")]
public int typeid { get; set; }
[DefaultValue(typeof(DateTime), DateTime.Now.ToString("yyyy-MM-dd HH:mm"))]
public DateTime adddate { get; set; } //private DateTime? dateCreated = null; //public DateTime DateCreated
//{
// get
// {
// return this.dateCreated.HasValue
// ? this.dateCreated.Value
// : DateTime.Now;
// } // set { this.dateCreated = value; }
//} public DateTime DateCreated
{
get
{
return (this.dateCreated == default(DateTime))
? this.dateCreated = DateTime.Now
: this.dateCreated;
} set { this.dateCreated = value; }
}
private DateTime dateCreated = default(DateTime); private bool myVal = false; [DefaultValue(false)]
public bool MyProperty
{
get
{
return myVal;
}
set
{
myVal = value;
}
} }

 http://stackoverflow.com/questions/691035/setting-the-default-value-of-a-datetime-property-to-datetime-now-inside-the-syst 

csharp: DefaultValueAttribute Class的更多相关文章

  1. c#操作MangoDB 之MangoDB CSharp Driver驱动详解

    序言 MangoDB CSharp Driver是c#操作mongodb的官方驱动. 官方Api文档:http://api.mongodb.org/csharp/2.2/html/R_Project_ ...

  2. c#进阶之神奇的CSharp

    CSharp 简写为c#,是一门非常年轻而又有活力的语言. CSharp的诞生      在2000年6月微软发布了c#这门新的语言.作为微软公司.NET 平台的主角,c#吸收了在他之前诞生的语言(c ...

  3. WindowsCE project missing Microsoft.CompactFramework.CSharp.targets in Visual Studio 2008

    00x0 前言 之前在Windows 7系统中开发的WindowsCE项目,最近换成Windows 10系统,需要将项目进行修改,打开项目后提示如下错误: 无法读取项目文件"App.cspr ...

  4. csharp: Oracle Stored Procedure DAL using ODP.NET

    paging : http://www.codeproject.com/Articles/44858/Custom-Paging-GridView-in-ASP-NET-Oracle https:// ...

  5. Excel转Json,Json转CSharp

    一份给策划最好的礼物!就是:Excel2Json2CSharp 策划配置Excel,动不动就要改数值啊,增加字段啊. 程序这边对应的解析类就得改动啊.整一个麻烦了得! 所以我就整理了这个Excel2J ...

  6. Microsoft.CompactFramework.CSharp.targets not found

    今天打开VS2008的智能设备项目,报以下错误,应该是文件找不到了. The imported project "C:\WINDOWS\Microsoft.NET\Framework\v3. ...

  7. CSharp 相关知识点小结

    1.JS获取iframe下面的内容document.getElementById('IFRAME1').contentDocument; 2.dialog 弹出层,定位:postion:'bottom ...

  8. 自己动手制作CSharp编译器

    在你喜欢的位置(如F盘根目录)新建一个文件夹,并命名为“CSharp开发环境”.找到或下载C#编译器组件(csc.exe和cscui.exe),并放在先前建立的文件夹中.该组件的一般位置在C盘的.NE ...

  9. Storm系列(二):使用Csharp创建你的第一个Storm拓扑(wordcount)

    WordCount在大数据领域就像学习一门语言时的hello world,得益于Storm的开源以及Storm.Net.Adapter,现在我们也可以像Java或Python一样,使用Csharp创建 ...

随机推荐

  1. Mac Terminal open app with a file opened

    open -a /Applications/Sublime Text.app test.cpp

  2. KMP string pattern matching

    The function used here is from the leetcode. Details can be found in leetcode problem: Implement str ...

  3. 五花八门的CSS

    一.颜色 rgba(0, 0, 0, 0.5) rgba括号中前3个数字代表着 red green blue三种颜色的rgb值,0-255,最后一个是设定这个颜色的透明度即alpha值.范围从0到1, ...

  4. koa-static与react-create-app搭配的路径

    概述 前端路由与后端路由的结合一直是一个难题.koa-static这个中间件能够把静态资源"搬到"后端路由上面去,react-create-app在不解构的情况下只会把资源打包到b ...

  5. 从零搭建java后台管理系统(二)mysql和redis安装

    接上篇开始安装mysql和redis 注意了,如果用阿里云服务器,外网访问的端口必须在安全组开启,否则外网访问不通 三.服务器安装redis和mysql 本次环境搭建将所有第三方服务会安装在阿里云服务 ...

  6. Shell-6--预定义变量

  7. Liferay7 BPM门户开发之17: Portlet 生命周期

    Portlet 生命周期 init() =〉 render() =〉 processAction() =〉 processEvent() =〉 serveResource() =〉destroy() ...

  8. for(var i=0;i<=3;i++){ setTimeout(function() { console.log(i) }, 10);}

    for(var i=0;i<=3;i++){ setTimeout(function() {  console.log(i)  }, 10);} 答案:打印4次4 这道题涉及了异步.作用域.闭包 ...

  9. Win10上安装Keras 和 TensorFlow(GPU版本)

    一. 安装环境 Windows 10 64bit  家庭版 GPU: GeForce GTX1070 Python: 3.5 CUDA: CUDA Toolkit 8.0 GA1 (Sept 2016 ...

  10. python学习之切片

    所谓切片,其实是列表的部分元素——Python称之为切片.要创建切片,可指定要使用的第一个元素和最后一个元素的索引 . players = ['charles', 'martina', 'michae ...