下面有一个字符串阵列:

 string[] elements = {"adsf","etwert" ,"asdfasd","gs"};


要求是获取元素最长或最短的长度。

你可以在程序中创建一个对象,这个对象有两个属性元素值和元素长度:
获取字符串阵列中元素最长或最短的长度

 

 class Class6
    {
        private string _ElementValue;

        public string ElementValue
        {
            get { return _ElementValue; }
            set { _ElementValue = value; }
        }       

        public int ElementLength
        {
            get {
                return _ElementValue.Length;
            }            
        }
     
        public Class6(string v)
        {
            _ElementValue = v;            
        }
    }
Source Code

相关文章: