Skip to content

Names -> Keywords batch 15 #6978

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// The following example uses BaseGetAllKeys and BaseGetAllValues to get an array of the keys or an array of the values.
// The following example uses BaseGetAllKeys and BaseGetAllValues to get an array of the keys or an array of the values.
// For an expanded version of this example, see the NameObjectCollectionBase class topic.

// <snippet1>
Expand All @@ -22,11 +22,11 @@ public DictionaryEntry this[ int index ] {
// Adds elements from an IDictionary into the new collection.
public MyCollection( IDictionary d ) {
foreach ( DictionaryEntry de in d ) {
this.BaseAdd( (String) de.Key, de.Value );
this.BaseAdd( (string) de.Key, de.Value );
}
}

// Gets a String array that contains all the keys in the collection.
// Gets a string array that contains all the keys in the collection.
public String[] AllKeys {
get {
return( this.BaseGetAllKeys() );
Expand All @@ -40,7 +40,7 @@ public Array AllValues {
}
}

// Gets a String array that contains all the values in the collection.
// Gets a string array that contains all the values in the collection.
public String[] AllStringValues {
get {
return( (String[]) this.BaseGetAllValues( typeof(System.String) ) );
Expand All @@ -63,7 +63,7 @@ public static void Main() {

// Displays the list of keys.
Console.WriteLine( "The list of keys:" );
foreach ( String s in myCol.AllKeys ) {
foreach ( string s in myCol.AllKeys ) {
Console.WriteLine( " {0}", s );
}

Expand All @@ -73,9 +73,9 @@ public static void Main() {
Console.WriteLine( " {0}", o.ToString() );
}

// Displays the list of values of type String.
Console.WriteLine( "The list of values (String):" );
foreach ( String s in myCol.AllValues ) {
// Displays the list of values of type string.
Console.WriteLine( "The list of values (string):" );
foreach ( string s in myCol.AllValues ) {
Console.WriteLine( " {0}", s );
}
}
Expand Down Expand Up @@ -103,7 +103,7 @@ The list of values (Object):
apple
banana
pear
The list of values (String):
The list of values (string):
apple
banana
pear
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// The following example uses BaseHasKeys to determine if the collection contains keys that are not a null reference.
// The following example uses BaseHasKeys to determine if the collection contains keys that are not a null reference.
// For an expanded version of this example, see the NameObjectCollectionBase class topic.

// <snippet1>
Expand All @@ -24,7 +24,7 @@ public MyCollection() {
}

// Adds an entry to the collection.
public void Add( String key, Object value ) {
public void Add( string key, Object value ) {
this.BaseAdd( key, value );
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// The following example uses BaseRemove and BaseRemoveAt to remove elements from a NameObjectCollectionBase.
// The following example uses BaseRemove and BaseRemoveAt to remove elements from a NameObjectCollectionBase.
// For an expanded version of this example, see the NameObjectCollectionBase class topic.

// <snippet1>
Expand All @@ -22,12 +22,12 @@ public DictionaryEntry this[ int index ] {
// Adds elements from an IDictionary into the new collection.
public MyCollection( IDictionary d ) {
foreach ( DictionaryEntry de in d ) {
this.BaseAdd( (String) de.Key, de.Value );
this.BaseAdd( (string) de.Key, de.Value );
}
}

// Removes an entry with the specified key from the collection.
public void Remove( String key ) {
public void Remove( string key ) {
this.BaseRemove( key );
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// The following example uses BaseSet to set the value of a specific element.
// The following example uses BaseSet to set the value of a specific element.
// For an expanded version of this example, see the NameObjectCollectionBase class topic.

// <snippet1>
Expand All @@ -19,7 +19,7 @@ public Object this[ int index ] {
}

// Gets or sets the value associated with the specified key.
public Object this[ String key ] {
public Object this[ string key ] {
get {
return( this.BaseGet( key ) );
}
Expand All @@ -28,7 +28,7 @@ public Object this[ String key ] {
}
}

// Gets a String array that contains all the keys in the collection.
// Gets a string array that contains all the keys in the collection.
public String[] AllKeys {
get {
return( this.BaseGetAllKeys() );
Expand All @@ -38,7 +38,7 @@ public String[] AllKeys {
// Adds elements from an IDictionary into the new collection.
public MyCollection( IDictionary d ) {
foreach ( DictionaryEntry de in d ) {
this.BaseAdd( (String) de.Key, de.Value );
this.BaseAdd( (string) de.Key, de.Value );
}
}
}
Expand Down Expand Up @@ -70,7 +70,7 @@ public static void Main() {
}

public static void PrintKeysAndValues2( MyCollection myCol ) {
foreach ( String s in myCol.AllKeys ) {
foreach ( string s in myCol.AllKeys ) {
Console.WriteLine( "{0}, {1}", s, myCol[s] );
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// The following example creates a read-only collection.
// The following example creates a read-only collection.
// For an expanded version of this example, see the NameObjectCollectionBase class topic.

// <snippet1>
Expand All @@ -22,13 +22,13 @@ public DictionaryEntry this[ int index ] {
// Adds elements from an IDictionary into the new collection.
public MyCollection( IDictionary d, Boolean bReadOnly ) {
foreach ( DictionaryEntry de in d ) {
this.BaseAdd( (String) de.Key, de.Value );
this.BaseAdd( (string) de.Key, de.Value );
}
this.IsReadOnly = bReadOnly;
}

// Adds an entry to the collection.
public void Add( String key, Object value ) {
public void Add( string key, Object value ) {
this.BaseAdd( key, value );
}
}
Expand Down Expand Up @@ -69,7 +69,7 @@ public static void PrintKeysAndValues( MyCollection myCol ) {
This code produces the following output.

System.NotSupportedException: Collection is read-only.
at System.Collections.Specialized.NameObjectCollectionBase.BaseAdd(String name, Object value)
at System.Collections.Specialized.NameObjectCollectionBase.BaseAdd(string name, Object value)
at SamplesNameObjectCollectionBase.Main()
Read-Only Collection:
[0] : red, apple
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// The following example shows how to implement and use the NameObjectCollectionBase class.
// The following example shows how to implement and use the NameObjectCollectionBase class.

// <snippet1>
using System;
Expand All @@ -14,7 +14,7 @@ public MyCollection() {
// Adds elements from an IDictionary into the new collection.
public MyCollection( IDictionary d, Boolean bReadOnly ) {
foreach ( DictionaryEntry de in d ) {
this.BaseAdd( (String) de.Key, de.Value );
this.BaseAdd( (string) de.Key, de.Value );
}
this.IsReadOnly = bReadOnly;
}
Expand All @@ -28,7 +28,7 @@ public DictionaryEntry this[ int index ] {
}

// Gets or sets the value associated with the specified key.
public Object this[ String key ] {
public Object this[ string key ] {
get {
return( this.BaseGet( key ) );
}
Expand All @@ -37,7 +37,7 @@ public Object this[ String key ] {
}
}

// Gets a String array that contains all the keys in the collection.
// Gets a string array that contains all the keys in the collection.
public String[] AllKeys {
get {
return( this.BaseGetAllKeys() );
Expand All @@ -51,7 +51,7 @@ public Array AllValues {
}
}

// Gets a String array that contains all the values in the collection.
// Gets a string array that contains all the values in the collection.
public String[] AllStringValues {
get {
return( (String[]) this.BaseGetAllValues( typeof( string ) ));
Expand All @@ -66,12 +66,12 @@ public Boolean HasKeys {
}

// Adds an entry to the collection.
public void Add( String key, Object value ) {
public void Add( string key, Object value ) {
this.BaseAdd( key, value );
}

// Removes an entry with the specified key from the collection.
public void Remove( String key ) {
public void Remove( string key ) {
this.BaseRemove( key );
}

Expand Down Expand Up @@ -144,7 +144,7 @@ public static void PrintKeysAndValues( MyCollection myCol ) {

// Prints the keys and values using AllKeys.
public static void PrintKeysAndValues2( MyCollection myCol ) {
foreach ( String s in myCol.AllKeys ) {
foreach ( string s in myCol.AllKeys ) {
Console.WriteLine( "{0}, {1}", s, myCol[s] );
}
}
Expand All @@ -155,7 +155,7 @@ public static void PrintKeysAndValues2( MyCollection myCol ) {
This code produces the following output.

System.NotSupportedException: Collection is read-only.
at System.Collections.Specialized.NameObjectCollectionBase.BaseAdd(String name, Object value)
at System.Collections.Specialized.NameObjectCollectionBase.BaseAdd(string name, Object value)
at SamplesNameObjectCollectionBase.Main()
Read-Only Collection:
[0] : red, apple
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System;
using System;
using System.Collections;
using System.Collections.Specialized;

Expand All @@ -11,7 +11,7 @@ public DerivedCollection() {
// Adds elements from an IDictionary into the new collection.
public DerivedCollection( IDictionary d, Boolean bReadOnly ) {
foreach ( DictionaryEntry de in d ) {
this.BaseAdd( (String) de.Key, de.Value );
this.BaseAdd( (string) de.Key, de.Value );
}
this.IsReadOnly = bReadOnly;
}
Expand All @@ -25,7 +25,7 @@ public DictionaryEntry this[ int index ] {
}

// Gets or sets the value associated with the specified key.
public Object this[ String key ] {
public Object this[ string key ] {
get {
return( this.BaseGet( key ) );
}
Expand All @@ -34,7 +34,7 @@ public Object this[ String key ] {
}
}

// Gets a String array that contains all the keys in the collection.
// Gets a string array that contains all the keys in the collection.
public String[] AllKeys {
get {
return( this.BaseGetAllKeys() );
Expand All @@ -48,7 +48,7 @@ public Array AllValues {
}
}

// Gets a String array that contains all the values in the collection.
// Gets a string array that contains all the values in the collection.
public String[] AllStringValues {
get {
return( (String[]) this.BaseGetAllValues( typeof( string ) ));
Expand All @@ -63,12 +63,12 @@ public Boolean HasKeys {
}

// Adds an entry to the collection.
public void Add( String key, Object value ) {
public void Add( string key, Object value ) {
this.BaseAdd( key, value );
}

// Removes an entry with the specified key from the collection.
public void Remove( String key ) {
public void Remove( string key ) {
this.BaseRemove( key );
}

Expand Down