using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ChangeStringToInt
{
class Program
{
static void Main(string[] args)
{
string str = "abcdef";
Console.WriteLine( ChangeToInt(str));
}
public static int ChangeToInt(string str)
{
int tot = 0;
char[] cStr;
cStr = str.ToCharArray();
for (int i = 0; i <= cStr.GetUpperBound(0); i++)
{
tot += (int)cStr[i];
}
return tot / cStr.GetUpperBound(0);
}
}
}
Friday, January 16, 2009
Subscribe to:
Post Comments (Atom)


No comments:
Post a Comment