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. 给uniGUI的表格控件uniDBGrid加上记录序号的列

    uniDBGrid使用起来还是很方便的,但就是没有显示记录序号的功能,必须自己加,参照老外给的解决方案如下: 方案1: 1- 在UniDBGrid建一个第一列 (列的名字起“NO”) 2- 在 Uni ...

  2. Spring 使用xml配置aop

    1.xml文件需要引入aop命名空间 2.xml内容: <?xml version="1.0" encoding="UTF-8"?> <bea ...

  3. wpf使用FFMEPG录制屏幕

    Simple function of recording screen based on ffmpeg Using WPF环境 Visual Studio 2017,dotNet Framework ...

  4. Android 使用View绘制文字(DrawText)技术总结

    转载请注明出处: http://www.cnblogs.com/renhui/p/7453534.html 这里的绘制文字不是直接调用TextView.setText(String content)去 ...

  5. 锚接口(上)——hashchange api 和 $.uriAnchor

    概述 这是我在单页Web应用这本书上看到的方法,并深入的研究了一下,把结果记录在下面,供以后开发时参考,相信对其它人也有用. 说明一下,这个方法已经过时了,H5有更新的方法:history api,我 ...

  6. 我自己的sublime3环境

    概述 我本来一直用的别人自带的破解版sublime3,自带插件. 前几天看<程序员修炼之道>,其中谈到了最好精通一种编辑器,我觉得说的很有道理,于是重新下了最新版的sublime3,一步步 ...

  7. Dispatch Queue 之 Invoke 当前队列

  8. 人脸检测第一文---A Dream of Spring

    人脸识别研究的人很多,可是,真正具有划时代意义的还要当属Paul Viola的一篇文章<RobustReal-time Object Detection>.这篇文章让 人脸识别在实际应用中 ...

  9. Leetcode:148_Sort List | O(nlogn)链表排序 | Medium

    题目:Sort List Sort a linked list in O(n log n) time using constant space complexity 看题目有两个要求:1)时间复杂度为 ...

  10. 线程误区-join,wait(里边还是调用的wait)

    1.一个线程执行结束后会执行该线程自身对象的notifyAll方法,这个是在jvm中实现的. 2.join的作用是:当我们调用某个线程的这个方法时,这个方法会挂起调用线程,直到被调用线程(thread ...