• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 79
  • Last Modified:

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

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"
1 Solution
Shaun KlineLead Software EngineerCommented:
You can use the Replace method on string objects:

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

Open in new window

AndyAinscowFreelance programmer / ConsultantCommented:
You just asked the same question:
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")
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now