?
Solved

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

Posted on 2016-08-24
2
Medium Priority
?
62 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 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

Create CentOS 7 Newton Packstack Running Keystone

A bug was filed against RDO for the installation of Keystone v3. This guide is designed to walk you through the configuration for using Keystone v3 with Packstack. You will accomplish this using various repos and the Answers file.

Question has a verified solution.

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

Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Suggested Courses

771 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