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


C# System.Char类代码示例

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


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

示例1: Write

        public void Write (Char[]! buffer, int index, int count) {
            CodeContract.Requires(buffer != null);
            CodeContract.Requires(index >= 0);
            CodeContract.Requires(count >= 0);
            CodeContract.Requires((buffer.Length - index) >= count);

        }
开发者ID:asvishnyakov,项目名称:CodeContracts,代码行数:7,代码来源:System.IO.StringWriter.cs

示例2: DataText

        XmlToken DataText(Char c)
        {
            while (true)
            {
                switch (c)
                {
                    case Symbols.LessThan:
                    case Symbols.EndOfFile:
                        Back();
                        return NewCharacters();

                    case Symbols.Ampersand:
                        _stringBuffer.Append(CharacterReference(GetNext()));
                        c = GetNext();
                        break;

                    case Symbols.SquareBracketClose:
                        _stringBuffer.Append(c);
                        c = CheckCharacter(GetNext());
                        break;

                    default:
                        _stringBuffer.Append(c);
                        c = GetNext();
                        break;
                }
            }
        }
开发者ID:fjwuyongzhi,项目名称:AngleSharp,代码行数:28,代码来源:XmlTokenizer.cs

示例3: VerifyInvalidReadValue

        private bool VerifyInvalidReadValue(int iBufferSize, int iIndex, int iCount, Type exceptionType)
        {
            bool bPassed = false;
            Char[] buffer = new Char[iBufferSize];

            ReloadSource();
            DataReader.PositionOnElement(ST_TEST_NAME);
            DataReader.Read();
            if (!DataReader.CanReadValueChunk)
            {
                try
                {
                    DataReader.ReadValueChunk(buffer, 0, 5);
                    return bPassed;
                }
                catch (NotSupportedException)
                {
                    return true;
                }
            }
            try
            {
                DataReader.ReadValueChunk(buffer, iIndex, iCount);
            }
            catch (Exception e)
            {
                CError.WriteLine("Actual   exception:{0}", e.GetType().ToString());
                CError.WriteLine("Expected exception:{0}", exceptionType.ToString());
                bPassed = (e.GetType().ToString() == exceptionType.ToString());
            }

            return bPassed;
        }
开发者ID:johnhhm,项目名称:corefx,代码行数:33,代码来源:ReadValue.cs

示例4: SubstituteArabicDigits

        /// <summary>
        /// based on http://weblogs.asp.net/abdullaabdelhaq/archive/2009/06/27/displaying-arabic-number.aspx
        /// seems like a fairly expensive method to call so not sure if its suitable to use this everywhere
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        public static string SubstituteArabicDigits(string input)
        {
            if (string.IsNullOrEmpty(input)) { return input; }

            Encoding utf8 = new UTF8Encoding();
            Decoder utf8Decoder = utf8.GetDecoder();
            StringBuilder result = new StringBuilder();

            Char[] translatedChars = new Char[1];
            Char[] inputChars = input.ToCharArray();
            Byte[] bytes = { 217, 160 };

            foreach (Char c in inputChars)
            {
                if (Char.IsDigit(c))
                {
                    // is this the key to it all? does adding 160 change to the unicode char for Arabic?
                    //So we can do the same with other languages using a different offset?
                    bytes[1] = Convert.ToByte(160 + Convert.ToInt32(char.GetNumericValue(c)));
                    utf8Decoder.GetChars(bytes, 0, 2, translatedChars, 0);
                    result.Append(translatedChars[0]);
                }
                else
                {
                    result.Append(c);
                }
            }

            return result.ToString();
        }
开发者ID:saiesh86,项目名称:TravelBlog,代码行数:36,代码来源:CultureHelper.cs

示例5: Form1_Load

        private void Form1_Load(object sender, EventArgs e)
        {
            siX = false;
            siO = false;
            Random r = new Random();
            if (r.Next(2) == 0)
                gracz = 'O';
            else
                gracz = 'X';
            for (int i = 0; i < k; i++)
            {
                AddAColumn(i);
            }
            dataGridView1.RowHeadersDefaultCellStyle.Padding = new Padding(3);
            for (int i = 0; i < k; i++)
            {
                AddARow(i);
            }

            t = new Char[dataGridView1.RowCount][];
            for (int i = 0; i < t.Length; i++)
            {
                t[i] = new Char[dataGridView1.ColumnCount];
                for (int j = 0; j < t[i].Length; j++)
                {
                    t[i][j] = ' ';
                    dataGridView1.Rows[i].Cells[j].Value = t[i][j].ToString();
                }
            }
            label2.Text = gracz.ToString();
            dataGridView1.ClearSelection();
        }
开发者ID:skamenialo,项目名称:Kolko_i_krzyzyk,代码行数:32,代码来源:Form1.cs

示例6: GetFirst

        /// <summary>取拼音第一个字段</summary>
        /// <param name="ch"></param>
        /// <returns></returns>
        public static String GetFirst(Char ch)
        {
            var rs = Get(ch);
            if (!String.IsNullOrEmpty(rs)) rs = rs.Substring(0, 1);

            return rs;
        }
开发者ID:g992com,项目名称:esb,代码行数:10,代码来源:PinYin.cs

示例7: DecodePixelData

        private static void DecodePixelData(ref Dictionary<Char, UInt32> upper, ref Dictionary<Char, UInt32> lower, ref Byte[] texturePixels, Char c, Int32 textureWidth)
        {
            Int32 charPstn = GetGlyphIndex(c);
            Int32 charTextureOffset = charPstn * FontWidth;
            Int32 halfway = FontWidth * FontHeight / 2;
            Boolean pixelIsLit;

            for (Int32 y = 0; y < FontHeight; y++)
            {
                Int32 textureRowPixelOffset = y * textureWidth;
                Int32 charRowPixelOffset = y * FontWidth;

                for (Int32 x = 0; x < FontWidth; x++)
                {
                    Int32 charPixelIndex =  x + charRowPixelOffset;

                    if(charPixelIndex < halfway)
                        pixelIsLit = ((upper[c] & (1 << charPixelIndex)) != 0);
                    else
                        pixelIsLit = ((lower[c] & (1 << (charPixelIndex - halfway))) != 0);

                    Int32 texturePixelIndex = textureRowPixelOffset + charTextureOffset + x;

                    texturePixels[texturePixelIndex] = pixelIsLit ? PixelLit : PixelDark;
                }
            }
        }
开发者ID:artron33,项目名称:PsmFramework,代码行数:27,代码来源:DebugFont.cs

示例8: POST

 private static string POST(string Url, string Data)
 {
     WebRequest req = WebRequest.Create(Url);
     req.Method = "POST";
     req.Timeout = 100000;
     req.ContentType = "application/x-www-form-urlencoded";
     byte[] sentData = Encoding.GetEncoding(1251).GetBytes(Data);
     req.ContentLength = sentData.Length;
     Stream sendStream = req.GetRequestStream();
     sendStream.Write(sentData, 0, sentData.Length);
     sendStream.Close();
     WebResponse res = req.GetResponse();
     Stream ReceiveStream = res.GetResponseStream();
     StreamReader sr = new StreamReader(ReceiveStream, Encoding.UTF8);
     //Кодировка указывается в зависимости от кодировки ответа сервера
     Char[] read = new Char[256];
     int count = sr.Read(read, 0, 256);
     string Out = String.Empty;
     while (count > 0)
     {
         String str = new String(read, 0, count);
         Out += str;
         count = sr.Read(read, 0, 256);
     }
     return Out;
 }
开发者ID:MrSyabro,项目名称:SyabroCraft,代码行数:26,代码来源:MainWindows.cs

示例9: SMSManager

        public SMSManager(Char receivingProjectCode, Char receivingProgramCode)
        {
            // check project code and program code availability.
            if (!arrayContains(usableCharset, receivingProjectCode))
                throw new ArgumentException("Project Code needs to be within accepted Charset");

            if (!arrayContains(usableCharset, receivingProgramCode))
                throw new ArgumentException("Program Code needs to be within accepted Charset");

            this.receivingProjectCode = receivingProjectCode;
            this.receivingProgramCode = receivingProgramCode;

            resendTimer = new System.Windows.Forms.Timer();

            /* Adds the event and the event handler for the method that will
            process the timer event to the timer. */
            resendTimer.Tick += new EventHandler(ResendFailedToSentMsgs);

            // Timer runs every 10 minutes.
            resendTimer.Interval = resendCheckInterval;
            resendTimer.Enabled = true;

            unfinishedSentMsgList = new Dictionary<String, SentMessage>();

            // create monitoring thread
            smsSendingMonitorThread = new Thread(new ThreadStart(smsSendingMonitor));
            smsSendingMonitorThread.Start();
        }
开发者ID:katadam,项目名称:wockets,代码行数:28,代码来源:SMSManager.cs

示例10: FindFiles

        public static List<DATFile> FindFiles(DAT dat, BinaryReader br)
        {
            List<DATFile> DatFiles = new List<DATFile>();

            uint FileIndex = 0;
            br.BaseStream.Seek(-(dat.TreeSize + 4), SeekOrigin.End);
            while (FileIndex < dat.FilesTotal)
            {
                DATFile file = new DATFile();
                file.br = br;
                file.FileNameSize = br.ReadInt32();
                char[] namebuf = new Char[file.FileNameSize];
                br.Read(namebuf, 0, (int)file.FileNameSize);
                file.Path = new String(namebuf, 0, namebuf.Length);
                file.FileName = Path.GetFileName(file.Path);
                file.Compression = br.ReadByte();
                file.UnpackedSize = br.ReadInt32();
                file.PackedSize = br.ReadInt32();
                if (file.Compression==0x00&&(file.UnpackedSize != file.PackedSize))
                        file.Compression = 1;
                file.Offset = br.ReadInt32();
                long oldoffset = br.BaseStream.Position;
                // Read whole file into a buffer
                br.BaseStream.Position = file.Offset;
                file.Buffer = new Byte[file.PackedSize];
                br.Read(file.Buffer, 0, file.PackedSize);
                br.BaseStream.Position = oldoffset;

                DatFiles.Add(file);
                FileIndex++;
            }
            return DatFiles;
        }
开发者ID:SnakeSolidNL,项目名称:CritterBrowser,代码行数:33,代码来源:DATReader.cs

示例11: GetEnvironment

        private Environment GetEnvironment(string credential)
        {
            var separators = new Char [] { '$' };
            var environment = credential.Split(separators)[1];

            return Environment.ParseEnvironment(environment);
        }
开发者ID:Jammyhammy,项目名称:braintree_dotnet,代码行数:7,代码来源:CredentialsParser.cs

示例12: Show

 internal static InputBoxResult Show(String prompt, String title, Char passwordChar)
 {
     LoadForm(title, prompt, string.Empty);
     frmInputDialog.AssignPasswordChar(passwordChar);
     frmInputDialog.ShowDialog();
     return OutputResponse;
 }
开发者ID:oo00spy00oo,项目名称:SharedTerminals,代码行数:7,代码来源:InputBox.cs

示例13: Create

		/// <summary>
		/// Creates a string from the specified character.
		/// </summary>
		/// <param name="c">
		/// The character to create the string from.
		/// </param>
		/// <param name="length">
		/// The number of instances of the specified character
		/// to construct the string from.
		/// </param>
		public static String Create(Char c, Int32 length) {
			StringBuilder sb = new StringBuilder(length);
			for (Int32 i = 0; i < length; i++) {
				sb.Append(c);
			}
			return sb.ToString();
		}
开发者ID:cyrusbuilt,项目名称:MonoPi,代码行数:17,代码来源:StringUtils.cs

示例14: button1_Click

        private void button1_Click(object sender, EventArgs e)
        {
            string sURL;
            sURL = "http://microsoft.com";

            HttpWebRequest myHttpWebRequest;
            myHttpWebRequest = (HttpWebRequest)WebRequest.Create(sURL);
            myHttpWebRequest.UserAgent = "leviticus2195 Test Client";

            HttpWebResponse myHttpWebResponse = (HttpWebResponse)myHttpWebRequest.GetResponse();
            Stream streamResponse = myHttpWebResponse.GetResponseStream();
            StreamReader streamRead = new StreamReader(streamResponse);
            Char[] readBuff = new Char[256];
            int count = streamRead.Read(readBuff, 0, 256);
            string content = "";
            while (count > 0)
            {
                String outputData = new String(readBuff, 0, count);
                content = content + outputData;
                count = streamRead.Read(readBuff, 0, 256);
            }
            // Release the response object resources.
            streamRead.Close();
            streamResponse.Close();
            myHttpWebResponse.Close();
            this.richTextBox1.AppendText(content);
        }
开发者ID:3141592,项目名称:vs,代码行数:27,代码来源:Form1.cs

示例15: TextDecl

        /// <summary>
        /// The text declaration for external DTDs.
        /// </summary>
        /// <param name="c">The character.</param>
        /// <returns>The token.</returns>
        protected DtdToken TextDecl(Char c)
        {
            if (_external)
            {
                var token = new DtdDeclToken();

                if (c.IsSpaceCharacter())
                {
                    c = SkipSpaces(c);

                    if (_stream.ContinuesWith(AttributeNames.VERSION))
                    {
                        _stream.Advance(6);
                        return TextDeclVersion(_stream.Next, token);
                    }
                    else if (_stream.ContinuesWith(AttributeNames.ENCODING))
                    {
                        _stream.Advance(7);
                        return TextDeclEncoding(_stream.Next, token);
                    }
                }
            }

            throw Errors.Xml(ErrorCode.DtdTextDeclInvalid);
        }
开发者ID:fjwuyongzhi,项目名称:AngleSharp,代码行数:30,代码来源:DtdPlainTokenizer.cs


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