473,587 Members | 2,505 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Problem setting string class to read-write

i have created a string class. later on i created a procedure where i
need to change charaters in the string. it seems to work just fine unitl
i want to assigm the new character values to a particular position in
the string [see starred lines at the bottom]. i get the error message
that the Property or Indexer is Read-only on compile. can anyone see
where i am going wrong? thanks in advance.
public class InputString
{
private string strParseString;

// A read-write instance property:
public string InStr
{
get
{
return strParseString;
}
set
{
strParseString = value;
}
}
}

public void CharaChange(str ing ssInStr, int nnInPos, int nnCnt)
{
char strTmp1;
char strTmp2;

InputString strCharaChange = new InputString();
strCharaChange. InStr = ssInStr;

strTmp1 = strCharaChange. InStr[nnInPos];
strTmp2 = strCharaChange. InStr[nnCnt];

strCharaChange. InStr[nnInPos] = strTmp2; //*************** ****
strCharaChange. InStr[nnCnt] = strTmp1; //*************** ****

}

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 15 '05 #1
1 1098
..NET strings are immutable.
You cannot change them, you can only create a new string and reassign it.

If you need to pass a "modifiable " string, you should pass a
System.Text.Str ingBuilder.

"travis powell" <he********@pro gun1.com> a écrit dans le message de
news:O5******** ******@TK2MSFTN GP10.phx.gbl...
i have created a string class. later on i created a procedure where i
need to change charaters in the string. it seems to work just fine unitl
i want to assigm the new character values to a particular position in
the string [see starred lines at the bottom]. i get the error message
that the Property or Indexer is Read-only on compile. can anyone see
where i am going wrong? thanks in advance.
public class InputString
{
private string strParseString;

// A read-write instance property:
public string InStr
{
get
{
return strParseString;
}
set
{
strParseString = value;
}
}
}

public void CharaChange(str ing ssInStr, int nnInPos, int nnCnt)
{
char strTmp1;
char strTmp2;

InputString strCharaChange = new InputString();
strCharaChange. InStr = ssInStr;

strTmp1 = strCharaChange. InStr[nnInPos];
strTmp2 = strCharaChange. InStr[nnCnt];

strCharaChange. InStr[nnInPos] = strTmp2; //*************** ****
strCharaChange. InStr[nnCnt] = strTmp1; //*************** ****

}

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Nov 15 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
5365
by: Bob | last post by:
I have an ASP.NET web application that has been running without any problems for a while. I recently transferred the site to shared hosting and had multiple users start to use the site. The problem I'm experiencing is that when many users are hitting the site at once, occasionaly I will see errors. The 3 most common ones are: "The SqlCommand is...
0
1730
by: Giulio Santorini | last post by:
Hi, I've got two drop down list controls. When I select a value from the first one I fill the second one. And when I select a value from the second one I would like to fill another control. But after have choose from the first control and filled the second... when I select something from the second control I have not the post back event! I...
0
394
by: Bob | last post by:
I have an ASP.NET web application that has been running without any problems for a while. I recently transferred the site to shared hosting and had multiple users start to use the site. The problem I'm experiencing is that when many users are hitting the site at once, occasionaly I will see errors. The 3 most common ones are: "The SqlCommand is...
1
3680
by: rory | last post by:
Have the following setting in my app.config: <setting name="Scenes" serializeAs="Xml"> <value> <ArrayOfString xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> <string>State Img;c:\scenes\Scene1\;5000;1;0;0;0;3</string> <string>Local
5
4072
by: Segfahlt | last post by:
I need a little help here please. I have 2 win forms user controls in 2 different projects that I'm hosting in 2 different virtual directories. The controls have been test and operate okay in both projects. Both controls(dlls) have been signed using SN.exe and I've set up the appropriate .Net assembly permissions using those Strong Names...
0
8215
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8347
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7973
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
6626
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
0
5394
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3844
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3879
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1454
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1189
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.