?
Solved

In C#, how would you replace one variable value with another, as per the example?

Posted on 2016-08-24
2
Medium Priority
?
72 Views
Last Modified: 2016-08-24
I am creating a C# application using .Net Framework 4.0.

I have a variable titled "file_tif" that has a value, for example, of  (X represents a number)    "2016XXXXXXXXXX_Front.TIF"
How would you replace the variable's value with                                                                            "2016XXXXXXXXXX.ard.out"
0
Comment
Question by:zimmer9
2 Comments
 
LVL 27

Expert Comment

by:Shaun Kline
ID: 41769156
You can use the Replace method on string objects:

file_tif.Replace("_Front.TIF", ".ard.out")

Open in new window

0
 
LVL 45

Accepted Solution

by:
AndyAinscow earned 2000 total points
ID: 41769166
You just asked the same question:
https://www.experts-exchange.com/questions/28965401/How-to-replace-a-fixed-position-value-with-another-another-value-in-C.html
and received an answer there.

Note that file_tif.Replace("_Front.TIF", ".ard.out") does NOT modify the variable file_tif you must do the following
file_tif = file_tif.Replace("_Front.TIF", ".ard.out")
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

For those of you who don't follow the news, or just happen to live under rocks, Microsoft Research released a beta SDK (http://www.microsoft.com/en-us/download/details.aspx?id=27876) for the Xbox 360 Kinect. If you don't know what a Kinect is (http:…
In real business world data are crucial and sometimes data are shared among different information systems. Hence, an agreeable file transfer protocol need to be established.
When cloud platforms entered the scene, users and companies jumped on board to take advantage of the many benefits, like the ability to work and connect with company information from various locations. What many didn't foresee was the increased risk…
With just a little bit of  SQL and VBA, many doors open to cool things like synchronize a list box to display data relevant to other information on a form.  If you have never written code or looked at an SQL statement before, no problem! ...  give i…
Suggested Courses
Course of the Month15 days, 16 hours left to enroll

850 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question