Skip to content

Names -> Keywords batch 3 #6927

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

Merged
Merged
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,12 +1,12 @@
using System;
using System;

public class SamplesArray2
{
public static void Main()
{
// <Snippet2>
// Creates and initializes a new three-dimensional Array of type Int32.
Array myArr = Array.CreateInstance(typeof(Int32), 2, 3, 4);
// Creates and initializes a new three-dimensional Array of type int.
Array myArr = Array.CreateInstance(typeof(int), 2, 3, 4);
for (int i = myArr.GetLowerBound(0); i <= myArr.GetUpperBound(0); i++)
{
for (int j = myArr.GetLowerBound(1); j <= myArr.GetUpperBound(1); j++)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
// <Snippet1>
// <Snippet1>
using System;

public class SamplesArray
{
public static void Main()
{
// Creates and initializes a new Array.
Array myIntArray = Array.CreateInstance(typeof(Int32), 5);
Array myIntArray = Array.CreateInstance(typeof(int), 5);

myIntArray.SetValue(8, 0);
myIntArray.SetValue(2, 1);
Expand All @@ -18,7 +18,7 @@ public static void Main()
Array.Sort(myIntArray);

// Displays the values of the Array.
Console.WriteLine( "The Int32 array contains the following:" );
Console.WriteLine( "The int array contains the following:" );
PrintValues(myIntArray);

// Locates a specific object that does not exist in the Array.
Expand Down Expand Up @@ -65,7 +65,7 @@ public static void PrintValues(Array myArr)
}
// This code produces the following output.
//
//The Int32 array contains the following:
//The int array contains the following:
// 2 3 6 7 8
//The object to search for (1) is not found. The next larger object is at index 0
//
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
// <Snippet1>
// <Snippet1>
using System;
public class SamplesArray {

public static void Main() {

// Creates and initializes a new Array of type Int32.
// Creates and initializes a new Array of type int.
Array myIntArray=Array.CreateInstance( typeof(System.Int32), 5 );
for ( int i = myIntArray.GetLowerBound(0); i <= myIntArray.GetUpperBound(0); i++ )
myIntArray.SetValue( i+1, i );
Expand All @@ -15,21 +15,21 @@ public static void Main() {
myObjArray.SetValue( i+26, i );

// Displays the initial values of both arrays.
Console.WriteLine( "Int32 array:" );
Console.WriteLine( "int array:" );
PrintValues( myIntArray );
Console.WriteLine( "Object array:" );
PrintValues( myObjArray );

// Copies the first element from the Int32 array to the Object array.
// Copies the first element from the int array to the Object array.
Array.Copy( myIntArray, myIntArray.GetLowerBound(0), myObjArray, myObjArray.GetLowerBound(0), 1 );

// Copies the last two elements from the Object array to the Int32 array.
// Copies the last two elements from the Object array to the int array.
Array.Copy( myObjArray, myObjArray.GetUpperBound(0) - 1, myIntArray, myIntArray.GetUpperBound(0) - 1, 2 );

// Displays the values of the modified arrays.
Console.WriteLine( "Int32 array - Last two elements should now be the same as Object array:" );
Console.WriteLine( "int array - Last two elements should now be the same as Object array:" );
PrintValues( myIntArray );
Console.WriteLine( "Object array - First element should now be the same as Int32 array:" );
Console.WriteLine( "Object array - First element should now be the same as int array:" );
PrintValues( myObjArray );
}

Expand All @@ -52,13 +52,13 @@ public static void PrintValues( Array myArr ) {
/*
This code produces the following output.

Int32 array:
int array:
1 2 3 4 5
Object array:
26 27 28 29 30
Int32 array - Last two elements should now be the same as Object array:
int array - Last two elements should now be the same as Object array:
1 2 3 29 30
Object array - First element should now be the same as Int32 array:
Object array - First element should now be the same as int array:
1 27 28 29 30
*/
// </Snippet1>
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@ public static void Main()
{

// Creates and initializes two new Arrays.
Array mySourceArray=Array.CreateInstance(typeof(String), 6);
Array mySourceArray=Array.CreateInstance(typeof(string), 6);
mySourceArray.SetValue("three", 0);
mySourceArray.SetValue("napping", 1);
mySourceArray.SetValue("cats", 2);
mySourceArray.SetValue("in", 3);
mySourceArray.SetValue("the", 4);
mySourceArray.SetValue("barn", 5);
Array myTargetArray=Array.CreateInstance(typeof(String), 15);
Array myTargetArray=Array.CreateInstance(typeof(string), 15);
myTargetArray.SetValue("The", 0);
myTargetArray.SetValue("quick", 1);
myTargetArray.SetValue("brown", 2);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ public class SamplesArray2
public static void Main()
{
// Creates and initializes the source Array.
Array myArrayZero=Array.CreateInstance(typeof(String), 3);
Array myArrayZero=Array.CreateInstance(typeof(string), 3);
myArrayZero.SetValue("zero", 0);
myArrayZero.SetValue("one", 1);

Expand All @@ -18,7 +18,7 @@ public static void Main()
// Creates and initializes the target Array.
int[] myArrLen = { 4 };
int[] myArrLow = { 2 };
Array myArrayTwo=Array.CreateInstance(typeof(String), myArrLen, myArrLow);
Array myArrayTwo=Array.CreateInstance(typeof(string), myArrLen, myArrLow);
myArrayTwo.SetValue("two", 2);
myArrayTwo.SetValue("three", 3);
myArrayTwo.SetValue("four", 4);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
// <Snippet1>
// <Snippet1>
using System;
public class SamplesArray {

public static void Main() {

// Creates and initializes a one-dimensional Array of type Int32.
Array my1DArray=Array.CreateInstance( typeof(Int32), 5 );
// Creates and initializes a one-dimensional Array of type int.
Array my1DArray=Array.CreateInstance( typeof(int), 5 );
for ( int i = my1DArray.GetLowerBound(0); i <= my1DArray.GetUpperBound(0); i++ )
my1DArray.SetValue( i+1, i );

Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
// <Snippet1>
// <Snippet1>
using System;
public class SamplesArray {

public static void Main() {

// Creates and initializes a two-dimensional Array of type String.
Array my2DArray=Array.CreateInstance( typeof(String), 2, 3 );
// Creates and initializes a two-dimensional Array of type string.
Array my2DArray=Array.CreateInstance( typeof(string), 2, 3 );
for ( int i = my2DArray.GetLowerBound(0); i <= my2DArray.GetUpperBound(0); i++ )
for ( int j = my2DArray.GetLowerBound(1); j <= my2DArray.GetUpperBound(1); j++ )
my2DArray.SetValue( "abc" + i + j, i, j );
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
// <Snippet1>
// <Snippet1>
using System;
public class SamplesArray {

public static void Main() {

// Creates and initializes a multidimensional Array of type String.
// Creates and initializes a multidimensional Array of type string.
int[] myLengthsArray = new int[4] { 2, 3, 4, 5 };
Array my4DArray=Array.CreateInstance( typeof(String), myLengthsArray );
Array my4DArray=Array.CreateInstance( typeof(string), myLengthsArray );
for ( int i = my4DArray.GetLowerBound(0); i <= my4DArray.GetUpperBound(0); i++ )
for ( int j = my4DArray.GetLowerBound(1); j <= my4DArray.GetUpperBound(1); j++ )
for ( int k = my4DArray.GetLowerBound(2); k <= my4DArray.GetUpperBound(2); k++ )
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
// <Snippet1>
// <Snippet1>
using System;
public class SamplesArray {

public static void Main() {

// Creates and initializes a multidimensional Array of type String.
// Creates and initializes a multidimensional Array of type string.
int[] myLengthsArray = new int[2] { 3, 5 };
int[] myBoundsArray = new int[2] { 2, 3 };
Array myArray=Array.CreateInstance( typeof(String), myLengthsArray, myBoundsArray );
Array myArray=Array.CreateInstance( typeof(string), myLengthsArray, myBoundsArray );
for ( int i = myArray.GetLowerBound(0); i <= myArray.GetUpperBound(0); i++ )
for ( int j = myArray.GetLowerBound(1); j <= myArray.GetUpperBound(1); j++ ) {
int[] myIndicesArray = new int[2] { i, j };
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System;
using System;

public class Example
{
Expand All @@ -16,7 +16,7 @@ public static void Main()
Console.WriteLine(" [{0,2}]: {1}", i, strings[i]);

// Search for the first occurrence of the duplicated value.
String searchString = "the";
string searchString = "the";
int index = Array.IndexOf(strings, searchString);
Console.WriteLine("The first occurrence of \"{0}\" is at index {1}.",
searchString, index);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
using System;
using System;
public class SamplesArray {

public static void Main() {

// <Snippet1>
// Creates and initializes a new Array with three elements of the same value.
Array myArray=Array.CreateInstance( typeof(String), 12 );
Array myArray=Array.CreateInstance( typeof(string), 12 );
myArray.SetValue( "the", 0 );
myArray.SetValue( "quick", 1 );
myArray.SetValue( "brown", 2 );
Expand All @@ -24,7 +24,7 @@ public static void Main() {
PrintIndexAndValues( myArray );

// Searches for the last occurrence of the duplicated value.
String myString = "the";
string myString = "the";
int myIndex = Array.LastIndexOf( myArray, myString );
Console.WriteLine( "The last occurrence of \"{0}\" is at index {1}.", myString, myIndex );

Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
// <Snippet1>
// <Snippet1>
using System;
public class SamplesArray {

public static void Main() {

// Creates and initializes a new Array.
Array myArray=Array.CreateInstance( typeof(String), 9 );
Array myArray=Array.CreateInstance( typeof(string), 9 );
myArray.SetValue( "The", 0 );
myArray.SetValue( "quick", 1 );
myArray.SetValue( "brown", 2 );
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
// <Snippet1>
// <Snippet1>
using System;
public class SamplesArray {

public static void Main() {

// Creates and initializes a new Array.
Array myArray=Array.CreateInstance( typeof(String), 9 );
Array myArray=Array.CreateInstance( typeof(string), 9 );
myArray.SetValue( "The", 0 );
myArray.SetValue( "QUICK", 1 );
myArray.SetValue( "BROWN", 2 );
Expand Down