本文介绍了将vb转换为c#的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在将vb代码转换为c#时遇到问题。 在vb中,他们使用了每个循环来更改可迭代变量 并且在 IF 条件下,他们正在将聊天数组与我遇到错误的字符串进行比较。 VB.NET代码:
I have a problem in converting the vb code to c# . In vb they have used for each loop where they are changing the iterable variable and in IF condition they are comparing chat array to string where i am getting an error . VB.NET CODE:
Dim rndAlphabet As New Random Dim rndAlphaDisplay As New Random For Each CharValue As Char In captchaDigit.ToCharArray Dim intAlphaDisplay As Integer = rndAlphaDisplay.Next(0, 9) If strAlphaDisplay.ToCharArray(intAlphaDisplay, 1) = "1" Then CharValue = alphabets(rndAlphabet.Next(0, 51)) End If nextC#代码:
C# code:
Random rndAlphabet = new Random(); Random rndAlphaDisplay = new Random(); foreach (char CharValue in captchaDigit.ToCharArray) { int intAlphaDisplay = rndAlphaDisplay.Next(0, 9); ) if (strAlphaDisplay.ToCharArray(intAlphaDisplay, 1) == "1") { CharValue = alphabets(rndAlphabet.Next(0, 51)); } }希望你能解决这个问题 提前感谢
hope you can fix this thanks in advance
推荐答案您好, ' VB '很容易让人忘记开发人员的一些精心设计的工作。 我不喜欢喜欢' VisualBasic.Net '因为它就像一辆自动驾驶汽车,但是一辆好车! 方式我觉得你可以试试这个: Hello, 'VB' takes it easy and it leds to be forgotten some elaborate works by developers. I don't like 'VisualBasic.Net' because it's like an automatic car, but a nice car! By the way I think you could try this: Random rndAlphabet = new Random(); Random rndAlphaDisplay = new Random(); foreach (char CharValue in captchaDigit.ToCharArray()) { int intAlphaDisplay = rndAlphaDisplay.Next(0, 9); if (strAlphaDisplay.ToCharArray(intAlphaDisplay, 1).First() == '1') { CharValue = alphabets(rndAlphabet.Next(0, 51)); } }
您好,试试这段代码它会解决您的问题并且很好^ _ ^: 随机rndAlphabet = new Random(); 随机rndAlphaDisplay = new Random(); Char xchar =''; foreach(Char CharValue in captchaDigit.ToCharArray()) {b int intAlphaDisplay = rndAlphaDisplay.Next(0,9); if(strAlphaDisplay.ToCharArray (intAlphaDisplay,1)。first()=='1') { xchar = Convert.ToChar(alphabets [rndAlphabet.Next(0,51)]。 ToString()); } else xchar = CharValue; } Hello, try this code it will fix your problem and have nice ^_^ : Random rndAlphabet = new Random(); Random rndAlphaDisplay = new Random(); Char xchar = ' '; foreach (Char CharValue in captchaDigit.ToCharArray()) { int intAlphaDisplay = rndAlphaDisplay.Next(0, 9); if (strAlphaDisplay.ToCharArray(intAlphaDisplay, 1).First() == '1') { xchar = Convert.ToChar(alphabets[rndAlphabet.Next(0, 51)].ToString()); } else xchar = CharValue; }
Random rndAlphabet = new Random(); Random rndAlphaDisplay = new Random(); foreach (char CharValue in captchaDigit.ToCharArray) { int intAlphaDisplay = rndAlphaDisplay.Next(0, 9); if (strAlphaDisplay.ToCharArray(intAlphaDisplay, 1) == "1") { CharValue = alphabets(rndAlphabet.Next(0, 51)); } }
更多推荐
将vb.net转换为c#的问题
发布评论