當前位置: 首頁>>代碼示例>>C#>>正文


C# Int32.Init方法代碼示例

本文整理匯總了C#中System.Int32.Init方法的典型用法代碼示例。如果您正苦於以下問題:C# Int32.Init方法的具體用法?C# Int32.Init怎麽用?C# Int32.Init使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在System.Int32的用法示例。


在下文中一共展示了Int32.Init方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: Main

	static int Main()
	{
	    Boolean pass=true;
#pragma warning disable 0436
	    Int32 a = new Int32();
	    a.Init("asdas");
	    TestLibrary.Logging.WriteLine(a);
	    Int32[] foo = new Int32 [] {a};
#pragma warning restore 0436
	    byte b = 0;

	    // GetByte
	    try
	    {
		b = Buffer.GetByte(foo, 0);
		pass=false;
		TestLibrary.Logging.WriteLine ("GetByte: No exception thrown!  Got 0x{0:x}", b);
	    }
	    catch (ArgumentException ex)
	    {
		TestLibrary.Logging.WriteLine("GetByte: Got expected exception: {0}: {1}", ex.GetType(), ex.Message);
	    }
	    catch (Exception ex)
	    {
		pass=false;
		TestLibrary.Logging.WriteLine("GetByte: Unexpected exception thrown: " + ex);
	    }
	    
	    // SetByte
	    try
	    {
		Buffer.SetByte(foo, 0, (Byte)2);
		pass=false;
		TestLibrary.Logging.WriteLine ("SetByte: No exception thrown!  Got 0x{0:x}", b);
	    }
	    catch (ArgumentException ex)
	    {
		TestLibrary.Logging.WriteLine("SetByte: Got expected exception: {0}: {1}", ex.GetType(), ex.Message);
	    }
	    catch (Exception ex)
	    {
		pass=false;
		TestLibrary.Logging.WriteLine("SetByte: Unexpected exception thrown: " + ex);
	    }

	    // BlockCopy
	    try
	    {
		Object[] arrObjects = new Object[3];
		Buffer.BlockCopy(foo, 0, arrObjects, 0, 4);
		pass=false;
		TestLibrary.Logging.WriteLine ("BlockCopy: No exception thrown!  Got 0x{0:x}", b);
	    }
	    catch (ArgumentException ex)
	    {
		TestLibrary.Logging.WriteLine("BlockCopy: Got expected exception: {0}: {1}", ex.GetType(), ex.Message);
	    }
	    catch (Exception ex)
	    {
		pass=false;
		TestLibrary.Logging.WriteLine("BlockCopy: Unexpected exception thrown: " + ex);
	    }
	    
	    if (pass)
	    {
		TestLibrary.Logging.WriteLine("Test passed.");
		return 100;
	    }
	    else
	    {
		TestLibrary.Logging.WriteLine("Test failed.");
		return 1;
	    }
	}
開發者ID:CheneyWu,項目名稱:coreclr,代碼行數:74,代碼來源:asurt_99893.cs


注:本文中的System.Int32.Init方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。