I am trying to create a filename in a class that is part of a data collection program. The verbatim construct works properly in the main program. However in the class method, trying to create a string using:
String teststring = @"\test stuff\;
creates the string \\test stuff\\
I also tried string teststring = "\\ test stuff\\; but got the same result.
Included below is a simple test program I put together to see what is happening that duplicates the problem.
Code:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace String_Test
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
NewClass.stringTest();
string test = @"/this is a test/";
test = test + "more string";
test = '/' + "more string";
int a = 1;
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace String_Test
{
static class NewClass
{
static string filename;
public static void stringTest()
{
filename = @"\this is a test\";
int a = 1;
}
}
}
The string in Form1.cs is created properly but the string in the class has the extra / issue. Any ideas of why this would be happening. I am using WinForms and added the class using the add option on the solution drop down menu.
Appreciate any help.