csharp基础练习题:获取长度【难度:1级】:
获取长度
你不会有任何想法是输入对象的类型,但你知道它有
长度
财产. (输入可以是任何类型的具有长度** 对象的属性**)
所以,** ** 对GetLength方法应返回输入的长度
.
编程目标:
using System;
public class Kata
{
public static int GetLength(/* get the input */)
{
// return the Length of input
}
}
测试样例:
using System;
using System.Dynamic;
using NUnit.Framework;
[TestFixture]
public class MyTest
{
[Test]
public void FirstTest()
int[] a = new int[] { 1, 2, 3, 4, 5 };
Assert.AreEqual(5,Kata.GetLength(a));
}
[Test]
public void SecondTest()
{
string a = "abcde";
最佳答案(多种解法):
更多关联题目:
免责申明
本博客所有编程题目及答案均收集自互联网,主要用于供网友学习参考,如有侵犯你的权益请联系管理员及时删除,谢谢
题目收集至https://www.codewars.com/
https://www.codewars.com/kata/get-length