Is there an alternative to string.Replace that is case

I need to search a string and replace all occurrences of %FirstName% and %PolicyAmount% with a value pulled from a database. The problem is the capitalization of FirstName varies. That prevents me from using the String.Replace() method. I've seen web pages on the subject that suggest Regex.Replace(strInput, strToken, strReplaceWith, RegexOptions.IgnoreCase); However for some reason when

有没有替代字符串。替换是大小写

我需要搜索一个字符串,并用从数据库中提取的值替换所有出现的%FirstName%和%PolicyAmount% 。 问题是FirstName的大写字母各不相同。 这阻止我使用String.Replace()方法。 我已经看到关于这个主题的网页 Regex.Replace(strInput, strToken, strReplaceWith, RegexOptions.IgnoreCase); 但是,由于某种原因,当我尝试用$0替换%PolicyAmount%时,替换从不会发生。 我认为这与美元符号是正则表达式中的保留字符有关。 有没

What is the difference between String and string in C#?

Example (note the case): string s = "Hello world!"; String s = "Hello world!"; What are the guidelines for the use of each? And what are the differences ? string is an alias in C# for System.String . So technically, there is no difference. It's like int vs. System.Int32 . As far as guidelines, it's generally recommended to use string any time you're referring to an object.

String和C#中的字符串有什么区别?

示例(注意案例): string s = "Hello world!"; String s = "Hello world!"; 什么是使用每个指导原则 ? 有什么区别 ? string是C#中System.String的别名。 从技术上讲,没有区别。 这就像int与System.Int32 。 就指导原则而言,通常建议您在引用某个对象时使用string 。 例如 string place = "world"; 同样,我认为一般建议使用String如果你需要特别提到该类。 例如 string greet = String.Format("Hello {0}

Passing Reference types by value in C#

I want to pass a reference type by value to a method in C#. Is there a way to do it. In C++, I could always rely on the copy constructor to come into play if I wanted to pass by Value. Is there any way in C# except: 1. Explicitly creating a new object 2. Implementing IClonable and then calling Clone method. Here's a small example: Let's take a class A in C++ which implements a cop

在C#中通过值传递引用类型

我想通过值传递一个引用类型到C#中的方法。 有没有办法做到这一点。 在C ++中,如果我想通过Value,我总是可以依靠复制构造函数来发挥作用。 在C#中有任何方法,除了:1.明确创建一个新的对象2.实现IClonable,然后调用克隆方法。 这是一个小例子: 让我们来看一个实现了复制构造函数的C ++类。 一个方法func1(Class a),我可以通过说func1(objA)来调用它(自动创建一个副本) C#中是否存在类似的东西? 顺

Parameters passed by value, still changed within the function?

This question already has an answer here: Passing Objects By Reference or Value in C# 7 answers C# pass by value/ref? 4 answers The function parameters are two Objects. If you change some object property in this function these properties will be changed outside the function. But if in your function you do obj = new Umfrage(); and will change properies all properties won't be chang

通过值传递的参数,仍然在函数内改变?

这个问题在这里已经有了答案: 在C#7答案中通过引用或值传递对象 C#传递值/ ref? 4个答案 函数参数是两个对象。 如果您在此函数中更改某些对象属性,则这些属性将在函数外部更改。 但如果在你的函数中你做obj = new Umfrage(); 并会改变属性,所有的属性都不会在外面改变。

by ref vs. by val, variable vs. array

This question already has an answer here: Passing Objects By Reference or Value in C# 7 answers When reference type object is passed by value, the reference to object is actually passed by value, so if you update the reference to a new object inside the method implementation the reference will start pointing to new memory address. You can see the difference in results by modifying a little

通过ref与val,变量与数组

这个问题在这里已经有了答案: 在C#7答案中通过引用或值传递对象 当引用类型对象通过值传递时,对象的引用实际上是按值传递的,因此如果在方法实现中更新引用到新对象,引用将开始指向新的内存地址。 您可以通过修改一些方法实现来查看结果的差异,以便将即将到来的输入数组初始化为一个新实例,如: static void method1(int[] z) { z = new int[3]; // new instance created and z has reference to it

C# array parameter reference

This question already has an answer here: Passing Objects By Reference or Value in C# 7 answers The array is passed by a reference, you can see this by doing A[0] = 7; from inside another method. That reference (held by the outer variable A ), however is passed by value to the function. The reference is copied and a new variable is created and passed to the function. The variable outside

C#数组参数引用

这个问题在这里已经有了答案: 在C#7答案中通过引用或值传递对象 所述阵列由引用传递,则可以通过执行看到这个A[0] = 7; 从另一种方法。 然而,该引用(由外部变量A )是按值传递给该函数的。 该引用被复制并创建一个新变量并传递给该函数。 函数外部的变量不受函数内部参数变量A的重新分配的影响。 要更新原始变量,需要使用ref关键字,以便函数内部的参数表示与函数外部相同的对象。 int[] A = new int[] {1, 2, 3

Why string value remains unchanged after calling function

This question already has an answer here: Passing Objects By Reference or Value in C# 7 answers Because you're changing the value of the parameter that's passed in, not the original value. ie str becomes a copy of x when you pass it in. Changing that makes no difference to the value stored in x . EDIT: Ok, that was an overly simplified explanation, but as pointed out, better expla

调用函数后为什么字符串值保持不变

这个问题在这里已经有了答案: 在C#7答案中通过引用或值传递对象 因为您要更改传入的参数的值,而不是原始值。 即当你传入时, str变成x一个副本。更改这对x存储的值没有影响。 编辑:好吧,这是一个过于简单的解释,但正如指出的,更好的解释已经可用。 蒂姆的权利,字符串是不可变的,所以你不能改变存储在该引用中的字符串的内容,你只能用新的字符串替换它,但除非你明确指定参数为'ref',否则不能改变方

Is really argument passing by value?

This question already has an answer here: C# pass by value vs. pass by reference 6 answers Passing Objects By Reference or Value in C# 7 answers After reading the page, what he is saying is this. Now remember that the value of a reference type variable is the reference, not the object itself. You can change the contents of the object that a parameter refers to without the parameter itsel

真的是有价值的传递吗?

这个问题在这里已经有了答案: C#传递值与传递引用6个答案 在C#7答案中通过引用或值传递对象 阅读完页面后,他说的是这个。 现在请记住,引用类型变量的值是引用,而不是对象本身。 您可以更改参数所引用的对象的内容,而不用通过引用传递参数。 public static void Main() { var s = new StringBuilder(); Console.WriteLine(s.ToString()); SayHello(s); Console.WriteLin

C# pointer to the variable

This question already has an answer here: Passing Objects By Reference or Value in C# 7 answers You are presumably looking for ref or out parameters: private void square(double input, out double output) { output = input * input; } For ref or out parameters, modifications made to the argument are made to the variable that the caller supplied. This is pass-by-reference rather than the de

C#指向变量的指针

这个问题在这里已经有了答案: 在C#7答案中通过引用或值传递对象 你大概在寻找ref或out参数: private void square(double input, out double output) { output = input * input; } 对于ref或out参数,对参数进行的修改是针对调用者提供的变量进行的。 这是通过引用而不是默认的按值传递。 像这样调用函数: double d; square(3.0, out d); Debug.Assert(d == 9.0); 通过out参数,信息从功能流向呼叫者。 ref参

c# how can i get the value of my printPreviewControl1 print to PDF

Hello guys good afternoon ? How can i get my printpreviewcontrol and display to pdf reader ? The pdf reader only read is document i want my to display my print to the pdf HERE'S THE PICTURE Code ` private void button1_Click(object sender, EventArgs e) { printPreviewDialog1.Document = printDocument1; printPreviewControl1.Document = printPreviewDialog1.Document; pri

c#我怎样才能得到我的printPreviewControl1打印到PDF的值

大家下午好吗? 我怎样才能让我的printpreviewcontrol和显示到PDF阅读器? PDF阅读器只读取文档,我希望我的图片显示在这里PDF文件 代码`private void button1_Click(object sender,EventArgs e){ printPreviewDialog1.Document = printDocument1; printPreviewControl1.Document = printPreviewDialog1.Document; printPreviewControl1.Show(); } private void printDocument1_PrintP