Solved

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

Posted on 2016-08-24
2
44 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 25

Expert Comment

by:Shaun Kline
Comment Utility
You can use the Replace method on string objects:

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

Open in new window

0
 
LVL 44

Accepted Solution

by:
AndyAinscow earned 500 total points
Comment Utility
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

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

We all know that functional code is the leg that any good program stands on when it comes right down to it, however, if your program lacks a good user interface your product may not have the appeal needed to keep your customers happy. This issue can…
More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

762 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

Need Help in Real-Time?

Connect with top rated Experts

8 Experts available now in Live!

Get 1:1 Help Now