当前位置: 首页>>代码示例>>C#>>正文


C# Byte.GetUpperBound方法代码示例

本文整理汇总了C#中System.Byte.GetUpperBound方法的典型用法代码示例。如果您正苦于以下问题:C# Byte.GetUpperBound方法的具体用法?C# Byte.GetUpperBound怎么用?C# Byte.GetUpperBound使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Byte的用法示例。


在下文中一共展示了Byte.GetUpperBound方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ReadSectionAllKey

        //public static string ReadSectionAllKey(string section)
        //{
        //    StringBuilder temp = new StringBuilder(512);
        //    GetPrivateProfileSection(section, temp, 512, __path);
        //    return temp.ToString();
        //    //string filePath = __path;

        //    //UInt32 MAX_BUFFER = 32767;

        //    //string[] items = new string[0];

        //    //IntPtr pReturnedString = Marshal.AllocCoTaskMem((int)MAX_BUFFER * sizeof(char));

        //    //UInt32 bytesReturned = GetPrivateProfileSection(section, pReturnedString, MAX_BUFFER, filePath);

        //    //if (!(bytesReturned == MAX_BUFFER - 2) || (bytesReturned == 0))
        //    //{
        //    //    string returnedString = Marshal.PtrToStringAuto(pReturnedString, (int)bytesReturned);

        //    //    items = returnedString.Split(new char[] { '\0' }, StringSplitOptions.RemoveEmptyEntries);
        //    //}

        //    //Marshal.FreeCoTaskMem(pReturnedString);

        //    //return items;
        //}

        /// <summary>  
        /// 获取INI文件中指定节点(Section)中的所有条目的Key列表  
        /// </summary>  
        /// <param name="iniFile">Ini文件</param>  
        /// <param name="section">节点名称</param>  
        /// <returns>如果没有内容,反回string[0]</returns>  
        public static string[] ReadSectionAllKey(string section)
        {
            int SIZE = 1024 * 10;

            if (string.IsNullOrEmpty(section))
            {
                throw new ArgumentException("必须指定节点名称", "section");
            }

            Byte[] Buffer = new Byte[16384];

            int bytesReturned = GetPrivateProfileString(section, null, null, Buffer, Buffer.GetUpperBound(0),__path);
            List<string> lt = new List<string>();

            if (bytesReturned != 0)
            {                                
                int start = 0;
                for (int i = 0; i < bytesReturned; i++)
                {
                    if ((Buffer[i] == 0) && ((i - start) > 0))
                    {
                        String s = Encoding.GetEncoding(0).GetString(Buffer, start, i - start);
                        lt.Add(s);
                        start = i + 1;
                    }
                }
            }


            return lt.ToArray();
        }  
开发者ID:SanHot,项目名称:JcMatrixSwitch,代码行数:64,代码来源:inifile.cs

示例2: ReadSections

 /// <summary>
 /// 读取指定节的所有键
 /// </summary>
 /// <param name="path"></param>
 /// <param name="section"></param>
 /// <param name="list"></param>
 public static void ReadSections(string path, string section, System.Collections.Specialized.StringCollection keys)
 {
     Byte[] buffer = new Byte[16384];
     long bufLen = GetPrivateProfileString(section, null, null, buffer, buffer.GetUpperBound(0), path);
     //对Section进行解析 
     GetStringsFromBuffer(buffer, bufLen, keys);
 }
开发者ID:jxdong1013,项目名称:archivems,代码行数:13,代码来源:IniUtil.cs

示例3: get

        public string get(string Ident)
        {
            Byte[] Buffer = new Byte[65535];
            int bufLen = GetPrivateProfileString(this.section, Ident, "", Buffer, Buffer.GetUpperBound(0), this.iniFile);
            string s = Encoding.GetEncoding(0).GetString(Buffer);

            return s.Substring(0, bufLen).Trim();
        }
开发者ID:pysche,项目名称:ponovosms,代码行数:8,代码来源:IniReader.cs

示例4: ReadString

 /*read string from ini file*/
 public string ReadString(string Section, string Ident, string Default)
 {
     Byte[] Buffer = new Byte[65535];
     int bufLen = GetPrivateProfileString(Section, Ident, Default, Buffer, Buffer.GetUpperBound(0), FileName);
     //set 0 to support chinese
     string s = Encoding.GetEncoding(0).GetString(Buffer);
     s = s.Substring(0, bufLen);
     return s.Trim();
 }
开发者ID:Mradxz,项目名称:XLoader,代码行数:10,代码来源:IniFileOp.cs

示例5: ReadSection

 public void ReadSection(String Section, StringCollection Idents)
 {
     Byte[] Buffer = new Byte[16384];
     Idents.Clear();
     int bufLen = getPrivateProfileString(Section, null, null,
         Buffer, Buffer.GetUpperBound(0), filename);
     //��Section�����
     getStringsFromBuffer(Buffer, bufLen, Idents);
 }
开发者ID:jihadbird,项目名称:firespider,代码行数:9,代码来源:IniFile.cs

示例6: readString

	//读取INI文件指定
	public string readString(string Section, string Ident, string Default)
	{
		Byte[] Buffer = new Byte[65535];
		int bufLen = GetPrivateProfileString(Section, Ident, Default, Buffer, Buffer.GetUpperBound(0), FileName);
		//必须设定0(系统默认的代码页)的编码方式,否则无法支持中文
		string s = Encoding.GetEncoding(0).GetString(Buffer);
		s = s.Substring(0, bufLen);
		return s.Trim();
	}
开发者ID:gfxmode,项目名称:LIB,代码行数:10,代码来源:IniHandler.cs

示例7: ReadTextFile

        ////读INI文件 
        ///// <summary>
        ///// 读取Ini文件方法
        ///// </summary>
        ///// <param name="Section">区域名称</param>
        ///// <param name="Key">项目名称</param>
        ///// <returns></returns>
        //public string ReadTextFile(string Section, string Key)
        //{
        //    StringBuilder strTemp = new StringBuilder(9000);
        //    int i = GetPrivateProfileString(Section, Key, "", strTemp, 9000, this._Path);
        //    return (strTemp.ToString().Trim().Equals("") ? Key : strTemp.ToString());
        //}

        //读INI文件 
        /// <summary>
        /// 读取Ini文件方法
        /// </summary>
        /// <param name="Section">区域名称</param>
        /// <param name="Key">项目名称</param>
        /// <returns>返回读取结果</returns>
        public string ReadTextFile(string Section, string Key)
        {
            Byte[] Buffer = new Byte[400];
            int bufLen = GetPrivateProfileString(Section, Key, "", Buffer, Buffer.GetUpperBound(0), this._Path);

            //以Utf-8的编码来显示的编码方式,否则无法支持日文操作系统
            System.Text.Encoding enc=System.Text.Encoding.UTF8;
            string s = enc.GetString(Buffer);
            return s.Replace("\0","").Trim();
  

        }
开发者ID:xlgwr,项目名称:producting,代码行数:33,代码来源:RWConfig..cs

示例8: GetData

        // ------------------------------------------------------------------------
        // Read values from textboxes
        // ------------------------------------------------------------------------
        private byte[] GetData(int num)
        {
            bool[] bits	= new bool[num];
            byte[] data	= new Byte[num];
            int[]  word	= new int[num];

            // ------------------------------------------------------------------------
            // Convert data from text boxes
            foreach(Control ctrl in grpData.Controls)
            {
                if (ctrl is TextBox)
                {
                    int x = Convert.ToInt16(ctrl.Tag);
                    if(radBits.Checked)
                    {
                        if((x <= bits.GetUpperBound(0)) && (ctrl.Text != "")) bits[x] = Convert.ToBoolean(Convert.ToByte(ctrl.Text));
                        else break;
                    }
                    if(radBytes.Checked)
                    {
                        if((x <= data.GetUpperBound(0)) && (ctrl.Text != "")) data[x] = Convert.ToByte(ctrl.Text);
                        else break;
                    }
                    if(radWord.Checked)
                    {
                        if ((x <= data.GetUpperBound(0)) && (ctrl.Text != ""))
                        {
                            try { word[x] = Convert.ToInt16(ctrl.Text); }
                            catch(SystemException) { word[x] = Convert.ToUInt16(ctrl.Text);};
                        }
                        else break;
                    }
                }
            }
            if(radBits.Checked)
            {
                int numBytes		= (byte)(num / 8 + (num % 8 > 0 ? 1 : 0));
                data				= new Byte[numBytes];
                BitArray bitArray	= new BitArray(bits);
                bitArray.CopyTo(data, 0);
            }
            if(radWord.Checked)
            {
                data = new Byte[num*2];
                for(int x=0;x<num;x++)
                {
                    byte[] dat = BitConverter.GetBytes((short) IPAddress.HostToNetworkOrder((short) word[x]));
                    data[x*2]	= dat[0];
                    data[x*2+1] = dat[1];
                }
            }
            return data;
        }
开发者ID:stephanstricker,项目名称:modbusTCP,代码行数:56,代码来源:frmStart.cs

示例9: ReadSection

        public void ReadSection(string Section, StringCollection Idents)
        {
            Byte[] Buffer = new Byte[16384];

            int bufLen = GetPrivateProfileString(Section, null, null, Buffer, Buffer.GetUpperBound(0),
             FileName);
            GetStringsFromBuffer(Buffer, bufLen, Idents);
        }
开发者ID:Mradxz,项目名称:XLoader,代码行数:8,代码来源:IniFileOp.cs

示例10: ReadString

 //��ȡINI�ļ�ָ��
 public string ReadString(string Section, string Ident, string Default)
 {
     Byte[] Buffer = new Byte[65535];
     int bufLen = GetPrivateProfileString(Section, Ident, Default, Buffer, Buffer.GetUpperBound(0), FileName);
     //�����趨0��ϵͳĬ�ϵĴ���ҳ���ı��뷽ʽ�������޷�֧������
     string s = Encoding.GetEncoding(0).GetString(Buffer);
     s = s.Substring(0, bufLen);
     return s.Trim();
 }
开发者ID:waitingzeng,项目名称:ttwait-code,代码行数:10,代码来源:DictIni.cs

示例11: RequestToSendOutputReport

		///  <summary>
		///  Sends an Output report.
		///  Assumes report ID = 0.
		///  </summary>

		private async void RequestToSendOutputReport()
		{
			const Int32 writeTimeout = 5000;
			String byteValue = null;

			try
			{
				//  If the device hasn't been detected, was removed, or timed out on a previous attempt
				//  to access it, look for the device.

				if (!_deviceHandleObtained)
				{
					_deviceHandleObtained = FindTheHid();
				}

				if (_deviceHandleObtained)
				{
					GetBytesToSend();
				}
				//  Don't attempt to exchange reports if valid handles aren't available
				//  (as for a mouse or keyboard.)

				if (!_hidHandle.IsInvalid)
				{
					//  Don't attempt to send an Output report if the HID has no Output report.

					if (_myHid.Capabilities.OutputReportByteLength > 0)
					{
						//  Set the size of the Output report buffer.   

						var outputReportBuffer = new Byte[_myHid.Capabilities.OutputReportByteLength];

						//  Store the report ID in the first byte of the buffer:

						outputReportBuffer[0] = 0;

						//  Store the report data following the report ID.
						//  Use the data in the combo boxes on the form.

						outputReportBuffer[1] = Convert.ToByte(CboByte0.SelectedIndex);

						if (outputReportBuffer.GetUpperBound(0) > 1)
						{
							outputReportBuffer[2] = Convert.ToByte(CboByte1.SelectedIndex);
						}

						//  Write a report.

						Boolean success;

						if (_transferType.Equals(TransferTypes.Control))
						{
							{
								_transferInProgress = true;

								//  Use a control transfer to send the report,
								//  even if the HID has an interrupt OUT endpoint.

								success = _myHid.SendOutputReportViaControlTransfer(_hidHandle, outputReportBuffer);

								_transferInProgress = false;
								cmdSendOutputReportControl.Enabled = true;
							}
						}
						else
						{
							Debug.Print("interrupt");
							_transferInProgress = true;

							// The CancellationTokenSource specifies the timeout value and the action to take on a timeout.

							var cts = new CancellationTokenSource();

							// Create a delegate to execute on a timeout.

							Action onWriteTimeoutAction = OnWriteTimeout;

							// Cancel the read if it hasn't completed after a timeout.

							cts.CancelAfter(writeTimeout);

							// Specify the function to call on a timeout.

							cts.Token.Register(onWriteTimeoutAction);

							// Send an Output report and wait for completion or timeout.

							success = await _myHid.SendOutputReportViaInterruptTransfer(_deviceData, _hidHandle, outputReportBuffer, cts);

							// Get here only if the operation completes without a timeout.

							_transferInProgress = false;
							cmdSendOutputReportInterrupt.Enabled = true;

							// Dispose to stop the timeout timer.
//.........这里部分代码省略.........
开发者ID:TeamVader,项目名称:CANBUS_MONITOR,代码行数:101,代码来源:FrmMain.cs

示例12: RequestToSendFeatureReport

		///  <summary>
		///  Sends a Feature report.
		///  Assumes report ID = 0.
		///  </summary>

		private void RequestToSendFeatureReport()
		{
			String byteValue = null;

			try
			{
				_transferInProgress = true;

				//  If the device hasn't been detected, was removed, or timed out on a previous attempt
				//  to access it, look for the device.

				if (!_deviceHandleObtained)
				{
					_deviceHandleObtained = FindTheHid();
				}

				if (_deviceHandleObtained)
				{
					GetBytesToSend();

					if ((_myHid.Capabilities.FeatureReportByteLength > 0))
					{
						//  The HID has a Feature report.
						//  Set the size of the Feature report buffer. 

						var outFeatureReportBuffer = new Byte[_myHid.Capabilities.FeatureReportByteLength];

						//  Store the report ID in the buffer.

						outFeatureReportBuffer[0] = 0;

						//  Store the report data following the report ID.
						//  Use the data in the combo boxes on the form.

						outFeatureReportBuffer[1] = Convert.ToByte(CboByte0.SelectedIndex);

						if (outFeatureReportBuffer.GetUpperBound(0) > 1)
						{
							outFeatureReportBuffer[2] = Convert.ToByte(CboByte1.SelectedIndex);
						}

						//  Write a report to the device

						Boolean success = _myHid.SendFeatureReport(_hidHandle, outFeatureReportBuffer);

						if (success)
						{
							DisplayReportData(outFeatureReportBuffer, ReportTypes.Feature, ReportReadOrWritten.Written);
						}
						else
						{
							CloseCommunications();
							AccessForm(FormActions.AddItemToListBox, "The attempt to send a Feature report failed.");
							ScrollToBottomOfListBox();
						}
					}

					else
					{
						AccessForm(FormActions.AddItemToListBox, "The HID doesn't have a Feature report.");
						ScrollToBottomOfListBox();
					}

				}
				_transferInProgress = false;
				cmdSendFeatureReport.Enabled = true;
				ScrollToBottomOfListBox();

			}
			catch (Exception ex)
			{
				DisplayException(Name, ex);
				throw;
			}
		}
开发者ID:TeamVader,项目名称:CANBUS_MONITOR,代码行数:80,代码来源:FrmMain.cs

示例13: GetSectionKey_StringValue

 //读操作
 public string GetSectionKey_StringValue(string section, string key, string value)
 {
     StringBuilder sb = new StringBuilder(500);
     Byte[] Buffer = new Byte[65535];
     int bufLen = GetPrivateProfileString(section, key, value, Buffer, Buffer.GetUpperBound(0), filePath);
     string s = Encoding.GetEncoding(0).GetString(Buffer);
     s = s.Substring(0, bufLen);
     return s.Trim();
 }
开发者ID:susnow,项目名称:LoLSignatureBuilder,代码行数:10,代码来源:INIConfig.cs

示例14: ReadSection

        //从Ini文件中,将指定的Section名称中的所有Ident添加到列表中
        public void ReadSection(string Section, StringCollection Idents)
        {
            Byte[] Buffer = new Byte[32768];
            //Idents.Clear();

            int bufLen = GetPrivateProfileString(Section, null, null, Buffer, Buffer.GetUpperBound(0),
            FileName);
            //对Section进行解析
            GetStringsFromBuffer(Buffer, bufLen, Idents);
        }
开发者ID:MsrButterfly,项目名称:CustomizedEmail,代码行数:11,代码来源:INIOperator.cs

示例15: clean

 internal static void clean(ref Byte[] Data)
 {
     for (int count = 0; count <= Data.GetUpperBound(0); count++)
     {
         Data[count] = (byte)new Random().Next((int)Byte.MinValue, (int)byte.MaxValue);
     }
 }
开发者ID:MetalMynds,项目名称:FlatGlass,代码行数:7,代码来源:CryptographicHelper.cs


注:本文中的System.Byte.GetUpperBound方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。