本文整理汇总了C#中System.Char.GetValue方法的典型用法代码示例。如果您正苦于以下问题:C# Char.GetValue方法的具体用法?C# Char.GetValue怎么用?C# Char.GetValue使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Char
的用法示例。
在下文中一共展示了Char.GetValue方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TestGetValueN
public void TestGetValueN() {
{
bool errorThrown = false;
try {
char[] c = new Char[2];
c.GetValue((int [])null);
} catch (ArgumentNullException) {
errorThrown = true;
}
Assert("#I61a", errorThrown);
}
{
bool errorThrown = false;
try {
char[] c = new Char[2];
int[] coords = {1, 1};
c.GetValue(coords);
} catch (ArgumentException) {
errorThrown = true;
}
Assert("#I62", errorThrown);
}
{
bool errorThrown = false;
try {
char[,] c = new Char[2,2];
int[] coords = {-1, 1};
c.GetValue(coords);
} catch (IndexOutOfRangeException) {
errorThrown = true;
}
Assert("#I63", errorThrown);
}
{
bool errorThrown = false;
try {
char[,] c = new Char[2,2];
int[] coords = {4, 1};
c.GetValue(coords);
} catch (IndexOutOfRangeException) {
errorThrown = true;
}
Assert("#I64", errorThrown);
}
char[,] c1 = new Char[4,6];
for (int i = 0; i < 24; i++) {
int first = i / 6;
int second = i % 6;
c1[first,second] = (char)(((int)'a')+i);
}
for (int i = 0; i < c1.GetLength(0); i++) {
for (int j = 0; j < c1.GetLength(1); j++) {
int[] coords = {i, j};
AssertEquals("#I65(" + i + "," + j + ")",
c1[i,j], c1.GetValue(coords));
}
}
}
示例2: TestGetValueLongArray
public void TestGetValueLongArray() {
char[] c = new Char[2];
c.GetValue((long [])null);
}
示例3: TestGetValue2
public void TestGetValue2() {
{
bool errorThrown = false;
try {
char[] c = new Char[2];
c.GetValue(1,1);
} catch (ArgumentException) {
errorThrown = true;
}
Assert("#I21", errorThrown);
}
{
bool errorThrown = false;
try {
char[,] c = new Char[2,2];
c.GetValue(-1, 1);
} catch (IndexOutOfRangeException) {
errorThrown = true;
}
Assert("#I22", errorThrown);
}
{
bool errorThrown = false;
try {
char[,] c = new Char[2,2];
c.GetValue(4,1);
} catch (IndexOutOfRangeException) {
errorThrown = true;
}
Assert("#I23", errorThrown);
}
char[,] c1 = new Char[4,6];
for (int i = 0; i < 24; i++) {
int first = i / 6;
int second = i % 6;
c1[first,second] = (char)(((int)'a')+i);
}
for (int i = 0; i < c1.GetLength(0); i++) {
for (int j = 0; j < c1.GetLength(1); j++) {
AssertEquals("#I24(" + i + "," + j + ")",
c1[i,j], c1.GetValue(i, j));
}
}
}
示例4: TestGetValue3
public void TestGetValue3() {
{
bool errorThrown = false;
try {
char[] c = new Char[2];
c.GetValue(1,1,1);
} catch (ArgumentException) {
errorThrown = true;
}
Assert("#I41", errorThrown);
}
{
bool errorThrown = false;
try {
char[,,] c = new Char[2,2,2];
c.GetValue(-1, 1, 1);
} catch (IndexOutOfRangeException) {
errorThrown = true;
}
Assert("#I42", errorThrown);
}
{
bool errorThrown = false;
try {
char[,,] c = new Char[2,2,2];
c.GetValue(4,1,1);
} catch (IndexOutOfRangeException) {
errorThrown = true;
}
Assert("#I43", errorThrown);
}
char[,,] c1 = new Char[4,2,3];
for (int i = 0; i < 24; i++) {
int first = i / 6;
int remains = i % 6;
int second = remains / 3;
int third = remains % 3;
c1[first,second, third] = (char)(((int)'a')+i);
}
for (int i = 0; i < c1.GetLength(0); i++) {
for (int j = 0; j < c1.GetLength(1); j++) {
for (int k = 0; k < c1.GetLength(2); k++) {
AssertEquals("#I44(" + i + "," + j + ")",
c1[i,j,k], c1.GetValue(i,j,k));
}
}
}
}
示例5: TestGetValue1
public void TestGetValue1() {
{
bool errorThrown = false;
try {
char[,] c = new Char[2,2];
c.GetValue(1);
} catch (ArgumentException) {
errorThrown = true;
}
Assert("#I01", errorThrown);
}
{
bool errorThrown = false;
try {
char[] c = {'a', 'b', 'c'};
c.GetValue(-1);
} catch (IndexOutOfRangeException) {
errorThrown = true;
}
Assert("#I02", errorThrown);
}
{
bool errorThrown = false;
try {
char[] c = {'a', 'b', 'c'};
c.GetValue(4);
} catch (IndexOutOfRangeException) {
errorThrown = true;
}
Assert("#I03", errorThrown);
}
char[] c1 = {'a', 'b', 'c', 'd'};
for (int i = 0; i < c1.Length; i++) {
AssertEquals("#I04(" + i + ")", c1[i], c1.GetValue(i));
}
}