有没有包含(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());