json转string示例
C#String.Insert()方法 (C# String.Insert() Method)
String.Insert() method is used to insert a string in an existence string at specified index and returns a new string.
String.Insert()方法用于在指定索引处的存在字符串中插入一个字符串,并返回一个新字符串。
Syntax:
句法:
public string String.Insert(int index, string value);
The method is called with "this" string i.e. the string in which we have to insert the string.
用“ this”字符串调用该方法,即我们必须在其中插入字符串的字符串。
Parameter(s):
参数:
index – represents the index/position of the current string where new string value to be inserted.
index –表示当前字符串的索引/位置,要在其中插入新的字符串值 。
value – a new string to be inserted.
value –要插入的新字符串。
Return value:
返回值:
string – it returns a new string containing the inserted string at given index.
string –返回一个新字符串,其中包含在给定索引处插入的字符串。
Example:
例:
Input:
string str = "IncludeHelp";
string str1 = " programming ";
Function call
str.Insert(7, str1);
Output:
Include programming Help
C#使用String.Insert()方法将字符串转换为字符数组的示例 (C# Example to convert string to characters array using String.Insert() method)
Example 1:
范例1:
using System;
class IncludeHelp
{
static void Main()
{
// declaring string variables
string str = "IncludeHelp";
// inserting space between Include and Help
string new_string = str.Insert(7, " ");
Console.WriteLine("str: " + str);
Console.WriteLine("new_string: " + new_string);
}
}
Output
输出量
str: IncludeHelp
new_string: Include Help
Example 2:
范例2:
using System;
class IncludeHelp
{
static void Main()
{
// declaring string variables
string str = "IncludeHelp";
string str1 = " programming ";
// inserting str1 after "Include"
string new_string = str.Insert(7, str1);
Console.WriteLine("str: " + str);
Console.WriteLine("new_string: " + new_string);
}
}
Output
输出量
str: IncludeHelp
new_string: Include programming Help
翻译自: https://www.includehelp.com/dot-net/string-insert-method-with-example-in-csharp.aspx
json转string示例