Choices.Add 메서드
정의
중요
일부 정보는 릴리스되기 전에 상당 부분 수정될 수 있는 시험판 제품과 관련이 있습니다. Microsoft는 여기에 제공된 정보에 대해 어떠한 명시적이거나 묵시적인 보증도 하지 않습니다.
대체 항목 집합에 항목을 추가합니다.
오버로드
| Name | Description |
|---|---|
| Add(GrammarBuilder[]) |
하나 이상의 GrammarBuilder 개체가 포함된 배열을 대안 집합에 추가합니다. |
| Add(String[]) |
하나 이상의 String 개체가 포함된 배열을 대안 집합에 추가합니다. |
Add(GrammarBuilder[])
- Source:
- Choices.cs
- Source:
- Choices.cs
- Source:
- Choices.cs
- Source:
- Choices.cs
하나 이상의 GrammarBuilder 개체가 포함된 배열을 대안 집합에 추가합니다.
public:
void Add(... cli::array <System::Speech::Recognition::GrammarBuilder ^> ^ alternateChoices);
public void Add(params System.Speech.Recognition.GrammarBuilder[] alternateChoices);
member this.Add : System.Speech.Recognition.GrammarBuilder[] -> unit
Public Sub Add (ParamArray alternateChoices As GrammarBuilder())
매개 변수
- alternateChoices
- GrammarBuilder[]
GrammarBuilder 이 Choices 개체에 추가할 개체입니다.
예제
다음 예제에서는 "휴대폰에서 Anne에게 전화", "회사 전화에서 James에게 전화"와 같은 문구에 대한 음성 인식 문법을 만듭니다. 이 예제에서는 메서드의 Add 오버로드를 모두 사용하여 문법을 작성합니다.
public Grammar CreatePhonePhrase()
{
// Create alternatives for female names and add a phrase.
GrammarBuilder females = new Choices(new string[] { "Anne", "Mary" });
females.Append("on her");
// Create alternatives for male names and add a phrase.
GrammarBuilder males = new Choices(new string[] { "James", "Sam" });
males.Append("on his");
// Create a Choices object that contains an array of alternative
// GrammarBuilder objects.
Choices people = new Choices();
people.Add(new Choices(new GrammarBuilder[] {females, males}));
// Create a Choices object that contains a set of alternative phone types.
Choices phoneType = new Choices();
phoneType.Add(new string[] { "cell", "home", "work" });
// Construct the phrase.
GrammarBuilder gb = new GrammarBuilder();
gb.Append("call");
gb.Append(people);
gb.Append(phoneType);
gb.Append(new GrammarBuilder("phone"), 0, 1);
return new Grammar(gb);
}
설명
개체에서 ChoicesSemanticResultKeySemanticResultValue 개체로의 암시적 변환을 GrammarBuilder지원하기 때문에 이러한 세 클래스도 인스턴스에 Choices 추가될 수 있습니다.
빈 배열인 경우 alternateChoices 이 메서드는 대체 집합을 업데이트하지 않습니다.
애플리케이션은 둘 다 Add(String[])Add(GrammarBuilder[]) 사용하고 개체에 대한 대안을 추가할 수 있습니다 Choices .
이 메서드는 ArgumentNullException 있는 경우 alternateChoicesnull 또는 배열 요소 중 어느 것이든 throw합니다 null.
추가 정보
적용 대상
Add(String[])
- Source:
- Choices.cs
- Source:
- Choices.cs
- Source:
- Choices.cs
- Source:
- Choices.cs
하나 이상의 String 개체가 포함된 배열을 대안 집합에 추가합니다.
public:
void Add(... cli::array <System::String ^> ^ phrases);
public void Add(params string[] phrases);
member this.Add : string[] -> unit
Public Sub Add (ParamArray phrases As String())
매개 변수
예제
다음 예제에서는 "그녀의 셀에서 Anne에게 전화" 및 "회사 전화에서 James에게 전화"와 유사한 구에 대한 음성 인식 문법을 만듭니다. 이 예제에서는 메서드의 Add 오버로드를 모두 사용하여 문법을 작성합니다.
public Grammar CreatePhonePhrase()
{
// Create alternatives for female names and add a phrase.
GrammarBuilder females = new Choices(new string[] { "Anne", "Mary" });
females.Append("on her");
// Create alternatives for male names and add a phrase.
GrammarBuilder males = new Choices(new string[] { "James", "Sam" });
males.Append("on his");
// Create a Choices object that contains an array of alternative
// GrammarBuilder objects.
Choices people = new Choices();
people.Add(new Choices(new GrammarBuilder[] {females, males}));
// Create a Choices object that contains a set of alternative phone types.
Choices phoneType = new Choices();
phoneType.Add(new string[] { "cell", "home", "work" });
// Construct the phrase.
GrammarBuilder gb = new GrammarBuilder();
gb.Append("call");
gb.Append(people);
gb.Append(phoneType);
gb.Append(new GrammarBuilder("phone"), 0, 1);
return new Grammar(gb);
}
설명
애플리케이션은 둘 다 Add(String[])Add(GrammarBuilder[]) 사용하고 개체에 대한 대안을 추가할 수 있습니다 Choices .
빈 배열인 경우 phrases 이 메서드는 대체 집합을 업데이트하지 않습니다.
이 메서드는 ArgumentNullException 있는 경우 phrasesnull 또는 배열 요소 중 어느 것이든 throw합니다 null. 이 메서드는 배열의 ArgumentException 요소가 빈 문자열("")인 경우 throw합니다.