首页 Soft PlugIn RAN乱 Dev开发 Info资料 English WAP 留言 登陆 注册
-
Posted by Yippee | 评论(0) | 引用(0) | 阅读66次
20080510 c# ParseExact StructLayout

20080510 c# ParseExact StructLayout
http://www.shengfang.org

http://www.ewangweb.com/website/4/231508.htm
威力强大的 DateTime.ParseExact

http://www.cnblogs.com/panzhilei/archive/2007/05/24/758595.aspx
统一项目时间格式(DateTime.ParseExact使用)

string   year   =   "2005";
                                string   mon   =   "05";
                                string   day   =   year   +   "-"   +   mon;
                                DateTime   date   =   DateTime.ParseExact(   day,   "yyyy-mm",   CultureInfo.CurrentCulture   );  

    从文本文件中读入数据时,遇到 "20061230" 这种日期格式,用C#的Convert.ToDateTime(string)方法,是不能进行转换的。查看了一下DateTime结构,发现ParseExact方法可以转化成DateTime结构,把代码贴在这里:

string dt = "20061230";                                                                                                                                                

DateTimeFormatInfo info1 = (DateTimeFormatInfo) Thread.CurrentThread.CurrentCulture.GetFormat(typeof(DateTimeFormatInfo));
DateTime time1 = DateTime.ParseExact(dt,"yyyyMMdd", info1, DateTimeStyles.AllowWhiteSpaces);

Console.WriteLine(time1 );

其中第二个参数格式数组,写了几个:

new string[] { "MMM d yyyy hh:mm:ss:ffftt", "MMM d yyyy hh:mm:ss:fff", "d MMM yyyy hh:mm:ss:ffftt", "d MMM yyyy hh:mm:ss:fff", "hh:mm:ss:ffftt", "hh:mm:ss:fff", "yyMMdd", "yyyyMMdd" };

http://hi.baidu.com/luckydogs888/blog/item/e3dabdd353f24cdba9ec9a82.html
用StructLayout特性限定声明结构或类

using System;
using System.Runtime.InteropServices;
using System.Text;

class Class1
{

    [StructLayout(LayoutKind.Sequential, CharSet=CharSet.Unicode)]
    public struct MyStruct
    {
        [MarshalAs(UnmanagedType.ByValTStr, SizeConst=4)] public string fname;
        [MarshalAs(UnmanagedType.ByValTStr, SizeConst=4)] public string lname;
        [MarshalAs(UnmanagedType.ByValTStr, SizeConst=7)] public string phone;
    }
   
    public static void Main()
    {
        string buffer = "abcdefgh2223333";
        IntPtr pBuf = Marshal.StringToBSTR(buffer);
        MyStruct ms = (MyStruct)Marshal.PtrToStructure(pBuf,typeof(MyStruct));
        Console.WriteLine("fname is: { 0 }",ms.fname);
        Console.WriteLine("lname is: { 0 }",ms.lname);
        Console.WriteLine("phone is: { 0 }",ms.phone);
        Marshal.FreeBSTR(pBuf);
    }
}

System.Configuration.Configuration rootWebConfig =
    System.Web.Configuration.WebConfigurationManager.OpenWebConfiguration("/MyWebSiteRoot");
System.Configuration.ConnectionStringSettings connString;
if (0 < rootWebConfig.ConnectionStrings.ConnectionStrings.Count)
{
    connString =
        rootWebConfig.ConnectionStrings.ConnectionStrings["NorthwindConnectionString"];
    if (null != connString)
        Console.WriteLine("Northwind connection string = \"{ 0 }\"",
            connString.ConnectionString);
    else
        Console.WriteLine("No Northwind connection string");
}

http://www.aspxboy.com/private/5487/default.aspx
Zip and Unzip files programmatically

Use java.util develop a C#.net zip tools
http://www.feelhum.com/aspx/Use-javautil-develop-a-Cnet-zip-tools-oqip0968.html

http://blog.sina.com.cn/s/print_4a5e327701000b3b.html
如何处理ASP.NET 2.0配置文件

http://www.chinaz.com/Program/.NET/060EM42007.html
ASP.NET 遍历配置文件的连接字符串

http://www.cnblogs.com/lxinxuan/archive/2007/01/25/630173.html
学习O/RM,从最简单的例子开始...之二

http://hi.baidu.com/21dacia/blog/item/f653fb09c92f9faa2eddd4bf.html
C#中配置文件的读写

select   datepart(mm,   datetemp),datepart(dd,   datetemp)   from   table  

http://zhidao.baidu.com/question/19501333.html
SQL提取月份~~

http://support.microsoft.com/kb/826766/zh-cn
如何通过在 Access 中使用函数和运算符与日期进行更改

http://blog.csdn.net/muyangquan823333/archive/2006/10/02/1317004.aspx
sql2005中时间日期函数的使用 

http://programfan.com/club/showtxt.asp?id=273830
C# 通过类名动态创建对象

加载程序集有两个函数,Assembly.Load()和Assembly.LoadFrom()。Assembly.Load的参数是程序集的名称,运行库会在本地目录和全局程序集高速缓存内搜索该程序集;Assembly.LoadFrom()的参数是程序集的完成路径名,不会在其它位置搜索该程序集。

http://www.cnblogs.com/futureflare/archive/2007/05/18/750687.html
用.net动态创建类的实例

http://blog.sina.com.cn/s/blog_40128d1801000930.html
利用反射动态调用类成员

如何用c#如何动态创建类
http://www.yinrg.com/Article/2007/10/31/200.html

http://hi.baidu.com/21tian/blog/item/7f719e166bf3e055f3de321c.html
关于反射中Assembly.CreateInstance()与Activator.CreateInstance()方法的区别

Type   t   =   Type.GetType(classID); 
  
                          Object   obj   =   (Object)Activator.CreateInstance(t);  

     我绕着Activator.CreateInstance跑
     http://popohei.spaces.live.com/blog/cns!8b95ae5e58bff0b6!120.entry

     http://blog.csdn.net/lanwilliam/archive/2008/05/05/2390764.aspx
      分层结构、反射与OR映射

      http://hi.baidu.com/tiankui6658/blog/item/df0c794faa1cb733aec3ab3f.html
      c# 反射的用法



字体:

Permanant URI永久地址 http://www.shengfang.org/blog/p/20080510csharpParseExactStructLayout.php
Trackback URI引用地址 http://www.shengfang.org/blog/tb.php?tb_id=1232986080

2009年1月27日00:08星期二  [Dev开发] 追踪此文的RSS
提示:
此文还没有评论。

称呼:    登陆   注册
   不注册,但记住我的信息
邮件:
(非必须)
评论: [UBB代码帮助]
粗体 斜体 下划线 链接 水平线 引用



验证码: 请输入你看见的数字
关闭UBB      提交时自动将内容复制到剪贴板

公告
Fire and Motion!

统计信息
[Yippee]||[统计]||日志:1790
在线: 10||用户: 2562 [列表]
今日:2359||到访:2677175
Rss:840220||评论:1584

最新日志

最新评论

友情链接

日历

最新引用

搜索

归档

杂项
Get RSS Feed (Version 2.0)
Get Atom Feed (Version 0.3)
编码:  UTF-8