|
-
Sep 30th, 2011, 02:17 PM
#1
Thread Starter
Hyperactive Member
[RESOLVED] Helping in Convert Code to C#
Hello,
I to find code in vb but i can't convert it to c#:
Code:
Dim Txt As String = ""
For Each Nass As String In TextBox1.Text
Nass = Regex.Replace(Nass, "[Aa]", "[Aa]")
Nass = Regex.Replace(Nass, "[Bb]", "[Bb]")
Nass = Regex.Replace(Nass, "[Cc]", "[Cc]")
Nass = Regex.Replace(Nass, "[Dd]", "[Dd]")
Nass &= "[ًٌٍَُِّْ]*"
Txt &= Nass
Next
I tried convert code by internet converter this result:
Code:
string Txt = "";
foreach (string Nass in txtBookTitle.Text)
{
Nass = Regex.Replace(Nass, "[Aa]", "[Aa]");
Nass = Regex.Replace(Nass, "[Bb]", "[Bb]");
Nass = Regex.Replace(Nass, "[Cc]", "[Cc]");
Nass = Regex.Replace(Nass, "[Dd]", "[Dd]");
Nass += "[ًٌٍَُِّْ]*";
Txt += Nass;
}
But get red line under Nass =
Please Help me
Thanks in advance
-
Sep 30th, 2011, 04:08 PM
#2
Re: Helping in Convert Code to C#
It looks right to me - what exactly is the error?
-
Oct 1st, 2011, 06:28 AM
#3
Thread Starter
Hyperactive Member
Re: Helping in Convert Code to C#
 Originally Posted by David Anton
It looks right to me - what exactly is the error?
I get Error on line 2: "Cannot assign to 'Nass' because it is a 'foreach ineration variable'"
Code:
1. For Each Nass As String In TextBox1.Text
2. Nass = Regex.Replace(Nass, "[Aa]", "[Aa]")
3. Nass = Regex.Replace(Nass, "[Bb]", "[Bb]")
4. Nass = Regex.Replace(Nass, "[Cc]", "[Cc]")
5. Nass = Regex.Replace(Nass, "[Dd]", "[Dd]")
6. Nass &= "[ًٌٍَُِّْ]*"
Txt &= Nass
Next
Last edited by waleed_89; Oct 1st, 2011 at 07:30 AM.
-
Oct 1st, 2011, 08:55 AM
#4
Re: Helping in Convert Code to C#
The error you are getting is pretty explanatory... you can't assign to a for each loop variable.
In a situation where you need to assign to an existing collection of variables you can use a For loop and the collections indexer.
In this case you do not appear to need any loop whatsoever as your code appears to be concerned with a single string.
Code:
string Txt = txtBookTitle.Text;
Txt = Regex.Replace(Txt , "[Aa]", "[Aa]");
Txt = Regex.Replace(Txt , "[Bb]", "[Bb]");
Txt = Regex.Replace(Txt , "[Cc]", "[Cc]");
Txt = Regex.Replace(Txt , "[Dd]", "[Dd]");
Txt += "[ًٌٍَُِّْ]*";
-
Oct 1st, 2011, 01:33 PM
#5
Thread Starter
Hyperactive Member
Re: [RESOLVED] Helping in Convert Code to C#
-
Oct 2nd, 2011, 11:03 PM
#6
Thread Starter
Hyperactive Member
Re: [RESOLVED] Helping in Convert Code to C#
Hello,
The problem solved after changed code Personal.master.cs to this code below:
Code:
<%@ Master Language="C#" MasterPageFile="~/Masters/MasterPage.master" AutoEventWireup="True" CodeFile="Personal.master.cs" Inherits="Personal" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
<table style="width:100%;">
<tr>
<td class="style5" align="right">
</td>
<td align="left" width="150">
<br />
</td>
</tr>
<tr>
<td align="right" class="style3" valign="top" dir="ltr">
<asp:ContentPlaceHolder id="ContentPlaceHolder1" runat="server">
</asp:ContentPlaceHolder>
</td>
<td align="left" valign="top" width="170">
<br />
</td>
</tr>
<tr>
<td class="style5" align="left">
<p style="margin-left: 20px"> </p></td>
<td>
</td>
</tr>
</table>
<div id="myslideshow"></div>
</asp:Content>
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|