Solved

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

Posted on 2016-08-24
2
60 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 26

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 44

Accepted Solution

by:
AndyAinscow earned 500 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
Finding and deleting duplicate (picture) files can be a time consuming task. My wife and I, our three kids and their families all share one dilemma: Managing our pictures. Between desktops, laptops, phones, tablets, and cameras; over the last decade…

734 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