C#中ref参数与out参数的区别
先贴代码
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Ref_and_Out_test
{
class Program
{
static void Main(string[] args)
{
int a =0; //若不初始化b会产生编译时错误。使用未初始化变量
int b = 1; //即使不初始化b也没有问题;
RefAndOut(ref a,out b);
Console.WriteLine("after RefAndOut method process");
Console.WriteLine("a={0},b={1}", a, b);
}
static void RefAndOut(ref int a,out int b)
{
//b = 1; //若此处不进行初始化,则try to print b这个语句无法执行
Console.WriteLine("before change ref a=0 and out b =1 value");
//try to print b:Console.WriteLine("a={0},b={1}", a, b);
Console.WriteLine("Now change the value,a to 123 ,b to 999");
a = 123;
b = 999; //若在方法内不对b赋值,则会出现编译时错误提醒必须对b赋值
&
相关文档:
using System;
using System.Collections.Generic;
using System.Text;
namespace ConsoleApplication2
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("/*\n------输出结果------------");
getSplit("ABCDEFG"); ......
1
<asp:UpdatePanelID="UpdatePanel1"
UpdateMode="Conditional"
runat="server">
<ContentTemplate>
<asp:Button ID="Button1"
......
C#
DataSet ds = new DataSet();
ds.ReadXml(Server.MapPath("~/Config/User_yhlx_Jb.xml"));
DataView dv = ds.Tables[0].DefaultView;
//dv.RowFilter = "State=0";
this.DropDownList1.DataSource = dv;
this.DropDownList1.DataTextField = "text";
this ......
原先一直用BinaryFormatter来序列化挺好,可是最近发现在WinCE下是没有办法进行BinaryFormatter操作,很不爽,只能改成了BinaryWriter和BinaryReader来读写,突然想到能不能用XML来序列化?于是在网上查了些资料便写了些实践性代码,做些记录,避免以后忘记。
序列化对象
public class People
......
/// <summary>
/// 支持XML序列化的泛型 Dictionary
/// </summary>
/// <typeparam name="TKey"></typeparam>
/// <typeparam name="TValue"></typeparam>
[XmlRoot("SerializableDictionary")]
public class SerializableDictionary<TKey, TValue& ......