c# 将枚举作为键值的形式存储
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Collections;
namespace 将枚举作为键值的形式存储
{
enum Myenum
{
First=3,
Second,
Third
}
class Program
{
static void Main(string[] args)
{
//用hashtable可以实现吗? NameValueCollection可以实现吗?
Dictionary<string, int> dictionary = new Dictionary<string, int>();
string [] enumArray=Enum.GetNames(typeof(Myenum));
for (int i = 0; i < enumArray.Length; i++)
{
dictionary.Add(enumArray[i],(int) Enum.Parse(typeof(Myenum), enumArray[i]));
}
Console.WriteLine(dictionary["First"]);
Console.WriteLine(dictionary["Second"]);
Console.WriteLine(dictionary["Third"]);
Console.Read();
}
}
}
相关文档:
/由于JAVA语言的数据类型都是有符号类型,而C# C++一般数据类型都是分有符号和无符号,
//因此在通信过程中传递的Byte[]无法直
接转换成C#需要的类型,
//以前倒是没注意这些细节,因为一般用一种语言编程,
//大都有内置的转换方法。跨语言环境的转换就的自己动
手想办法了。
1、java的Byte[]转换成c#的Int32
privat ......
public partial class shujuku_huanyuan : System.Web.UI.Page
{
SqlConnection conn = new SqlConnection(@"server=HUAZD-33\XXD33;uid=sa;pwd=111111;database=master;");
protected void Page_Load(object sender, EventArgs e)
&nbs ......
新建一个专门用来创建验证码图片的页面ValidateCode.aspx
它的后台cs文件代码如下:
PageLoad
private void Page_Load(object sender, System.EventArgs e)
{
string checkCode = CreateRandomCode(4);
Session["CheckCode"] = checkCode;
CreateImage(checkCode);
......
C# access日期查询加#
if (((string)((ComboBoxItem)cmbField.SelectedItem).Value).Equals("System.DateTime"))
{
//判断日期的;
& ......
以下参考 :http://msdn.microsoft.com/zh-cn/library/87d83y5b.aspx
接口(C# 参考)
更新:2007 年 11 月
接口只包含方法、属性、事件或索引器的签名。成员的实现是在实现接口的类或结构中完成的,如下面的示例所示:
示例
interface ISampleInterface
{
void SampleMethod();
}
class Implem ......