javascript中'charAt'方法的等效C#方法是什么? [英] what is equivalent C# method for the 'charAt' method in javascript?

查看:94
本文介绍了javascript中'charAt'方法的等效C#方法是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

什么是javascript方法"charAt"的等效C#方法?

what is equivalent C# method for the javascript method ''charAt''?

推荐答案

我认为您的意思是
I think you mean
string alphabet = "abcdefg...xyz" ;
char b = alphabet[1] ;


在询问诸如此类问题之前(通常,而不是通常)先阅读MSDN: http://msdn.microsoft.com/en-us/library/system.string.aspx [
Always read MSDN before (and typically, instead of) asking such questions: http://msdn.microsoft.com/en-us/library/system.string.aspx[^].

Asking such question at CodeProject is very ineffective compared to reading MSDN help pages, which you should do in all cases anyway.

—SA


回答第二个问题,即
In answer to your second question, namely
maajanes写道:
maajanes wrote:


我必须计算一个特定角色的出现次数.我该怎么办?


I have to count the number of occurances of a particular character. What can i do?



我遇到的最快模式 0



The fastest pattern I have come across0 is

string source = "this is my test string";
char requiredCharacter = 's';
int count = 0;
foreach (char c in source)
{
   if (c == requiredCharacter)
   {
       count++;
   }
}


0
不记得原来是从前一段时间来的,但这是我现在使用的


0
Can''t remember were the original came from as it was a while ago, but it is what I use now


这篇关于javascript中'charAt'方法的等效C#方法是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆