글
WEB/ASP.NET With C# 2007. 3. 14. 11:55RealLength
string의 길이를 구한다. < > 를 '<', '>'로 계산해서..
귀찮아서 만들었는데 결국 쓰지는 않는...OTL
public int RealLength(string strRetString)
{
// '<' 의 개수를 센다.
int i =0;
int cntCharLT = 0;
while(i < strRetString.Length)
{
i = strRetString.IndexOf("<", i);
if(i != -1 && i < strRetString.Length)
{
cntCharLT = cntCharLT + 1;
i= i+4;
}
if(i == -1)
break;
}
// '>'의 개수를 센다.
int j =0;
int cntCharGT = 0;
while(j < strRetString.Length)
{
j = strRetString.IndexOf(">", j);
if(j != -1 && j < strRetString.Length)
{
cntCharGT = cntCharGT + 1;
j= j+4;
}
if(j == -1)
break;
}
int realLength = (strRetString.Length - cntCharGT*3- cntCharLT*3);
return realLength;
}
RECENT COMMENT