有没有包含(A-Z)字母的代码? [英] Is there Any Code to include (A-Z) Letters?

查看:72
本文介绍了有没有包含(A-Z)字母的代码?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有什么方法可以编写包含数字(1-10)&的简短代码.字母(A-Z).. ??我的意思是没有全部写成一行?

**和顺便说一句...该代码不支持Words? ..我的意思是当我说没有在此输入的单词时..它可以使..
有什么办法吗?



is there any way to write a short code that includes the number (1-10) & Letters (A-Z) ..?? i mean without writing all of it in single lines?

** and btw... the code doesn''t support Words? .. i mean when i say a word that doesn''t typed there.. it can heart it ..
is there any way to do it ?



using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.IO;
using System.Speech;

namespace System.Speech.Recognition
{
    public partial class Form1 : Form
    {
        SpeechRecognizer rec = new SpeechRecognizer();

        public Form1()
        {
            InitializeComponent();
            rec.SpeechRecognized += rec_SpeechRecognized;
        }

        void rec_SpeechRecognized(object sender, SpeechRecognizedEventArgs e)
        {
            lblLetter.Text = e.Result.Text;
        }

        void Form1_Load(object sender, EventArgs e)
        {
            var c = new Choices();

            // Doens''t work must use English words to add to Choices and
            // populate grammar.
            //
            //for (var i = 0; i <= 100; i++)
            //  c.Add(i.ToString());

            c.Add("one");
            c.Add("two");
            c.Add("three");
            c.Add("four");
            c.Add("hi");
            c.Add("hello");
            c.Add("I");
            c.Add("A");
            c.Add("B");
            c.Add("C");
            c.Add("D");
            c.Add("amer");
            // etc...

            var gb = new GrammarBuilder(c);
            var g = new Grammar(gb);
            rec.LoadGrammar(g);
            rec.Enabled = true;
        }

        private void lblLetter_Click(object sender, EventArgs e)
        {

        }

    }
}

推荐答案

有什么问题:
What''s wrong with:
for (char letter = ''A''; letter <= ''Z''; ++letter)
    c.Add(letter.ToString());


这应该让您入门:
This should get you started:
string letterA = ((char)97).ToString();
string letterZ = ((char)(97 + 25)).ToString();
MessageBox.Show(letterA + "-" + letterZ);
MessageBox.Show(1.ToString() + "-" + 10.ToString());


这篇关于有没有包含(A-Z)字母的代码?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆