将vb.net转换为c#的问题

编程入门 行业动态 更新时间:2024-10-26 01:20:48
本文介绍了将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 next

C#代码:

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#的问题

本文发布于:2023-05-27 23:12:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/306119.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:转换为   vb   net

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!