"IndexOf("?)"是什么意思? ? [英] what mean "IndexOf("?")" ?

查看:156
本文介绍了"IndexOf("?)"是什么意思? ?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

朋友,

该代码是什么意思

hi friends,

what mean this code

filename = verbs[1].Replace("/", "\\");
            if (filename.IndexOf("?") != -1)
            {
                // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
                filename = filename.Substring(0, filename.IndexOf("?"));
            }




恰好




exactly

if(filename.IndexOf("?") != -1)



谢谢



thank you

推荐答案

IndexOf方法返回给定子字符串在字符串中的位置并返回一个数字.如果未找到子字符串,则返回-1.

在您的情况下,仅当filename包含?"时,才会执行if语句中的代码.角色.

请参见 String.IndexOf()
The IndexOf method returns the position of the given substring inside a string and returns a number. If the substring is not found, it returns -1.

In your case the code inside the if statement will only execute if filename contains the "?" character.

See String.IndexOf()


此检查原始字符串中的字符/字符串部分(-1表示它不是字符串的一部分).在问这些问题之前,您应该自己尝试一下.
This checks for the character/string part in the original string (-1 means that it is not part of the string). Before asking such questions you should try something yourself.


这意味着返回?"字符首次出现的位置.真的,一个简单的Google搜索就会告诉您IndexOf方法的作用.

编辑===================

为什么要对此进行1票表决.答案是正确的.
It means return the position of the first occurance of the ''?'' character. Really, a simple google search would have told you what the IndexOf method does.

EDIT ====================

Why was this 1-voted. It''s the correct freakin'' answer.


这篇关于"IndexOf("?)"是什么意思? ?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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