小编AAH*_*oot的帖子

C#字符串拆分

如果我有一个字符串:str1|str2|str3|srt4并用|分隔符解析它.我的输出是str1 str2 str3 str4.

但如果我有一个字符串:str1||str3|str4输出将是str1 str3 str4.我正在寻找的输出是什么样的str1 null/blank str3 str4.

我希望这是有道理的.

string createText = "srt1||str3|str4";
string[] txt = createText.Split(new[] { '|', ',' },
                   StringSplitOptions.RemoveEmptyEntries);
if (File.Exists(path))
{
    //Console.WriteLine("{0} already exists.", path);
    File.Delete(path);
    // write to file.

    using (StreamWriter sw = new StreamWriter(path, true, Encoding.Unicode))
    {
        sw.WriteLine("str1:{0}",txt[0]);
        sw.WriteLine("str2:{0}",txt[1]);
        sw.WriteLine("str3:{0}",txt[2]);
        sw.WriteLine("str4:{0}",txt[3]);
    }
}
Run Code Online (Sandbox Code Playgroud)

产量

str1:str1
str2:str3
str3:str4
str4:"blank"
Run Code Online (Sandbox Code Playgroud)

那不是我想要的.这就是我想编码的内容:

str1:str1
str2:"blank"
str3:str3
str4:str4
Run Code Online (Sandbox Code Playgroud)

c# string

4
推荐指数
2
解决办法
3万
查看次数

C# - 从字符串数组向文件写入文本的最佳方法是什么

组,

我正在寻找新的有趣的方法来将字符串数组写入.txt文件. - 每次调用和保存时,都会重写该文件. - 文件名将足够动态,以便.exe将知道字符串在哪里.

例如:

 ~/someFile.exe "fileName" "string|string|string|"
Run Code Online (Sandbox Code Playgroud)

- 在此示例中,调用someFile.exe将字符串写入此"fileName".

有什么建议?

乍得

.net streamwriter c#-3.0

3
推荐指数
1
解决办法
1251
查看次数

Max(char)真的如何运作?

有人请解释一下:

我有专栏

        c_1
        ----
         A
         P
         H
         D

    Why?

    SELECT MAX(c_1) 
    FROM tbl_1 

Returns 
----
 P
Run Code Online (Sandbox Code Playgroud)

我只能假设为十六进制:A = 41,P = 50,H = 48,D = 44; 因此P是最大值.

情况并非如此,因为如果我有的话

        c_1
        -----
         A
         |
         }
         ~

  Returns

   -----
     A
Run Code Online (Sandbox Code Playgroud)

在Hex'〜'是7E,为什么不'〜'?

sql t-sql sql-server

3
推荐指数
1
解决办法
151
查看次数

WseWsdl3.exe在Windows 7 Professional 64位上生成错误

当我运行命令时:

 "C:\Program Files (x86)\Microsoft WSE\v3.0\Tools\WseWsdl3.exe" [WSDL location] /o:[file location] /l:cs /type:webClient
Run Code Online (Sandbox Code Playgroud)

其中[WSDL location]是本地计算机上Web服务的位置,[file location]是我的webService.asmx.cs文件位置的位置

我收到错误:

    System.InvalidOperationException: Could not get the install directory for .NET F
ramework v2.0 SDK. Please install the .NET Framework v2.0 SDK.
   at WseWsdl.WebServiceUtil.RunWsdl(String[] args)
Run Code Online (Sandbox Code Playgroud)

我谷歌这种错误,发现一个有用的链接WseWsdl3.exe在Windows 7 Ultimate 64位上生成错误由Robert Amiscaray 19.2009年11月11:31

我已经做了建议的更改,仍然得到相同的错误.
博客条目是正确的还是我需要做一些特殊的更改b/c我正在使用"Win 7 Pro Sp 1"?

asp.net wsdl windows-7-x64

1
推荐指数
1
解决办法
3722
查看次数

将CSV字符串解析为整数数组

我有一个文本框字段输入123,145,125我将这个字段分成一个整数数组.如果所有内容都被正确解析,则验证此字段是true还是false.

码:

private bool chkID(out int[] val) 
{
    char[] delimiters = new char[] { ',' };
    string[] strSplit = iconeID.Text.Split(delimiters);  


    int[] intArr = null;
    foreach (string s in strSplit) //splits the new parsed characters 
    {
        int tmp;
        tmp = 0;
        if (Int32.TryParse(s, out tmp))
        {
            if (intArr == null)
            {
                intArr = new int[1];
            }
            else
            {
                Array.Resize(ref intArr, intArr.Length + 1);
            }
            intArr[intArr.Length - 1] = tmp;
        }

        if (Int32.TryParse(iconeID.Text, out tmp))
        {
            iconeID.BorderColor = Color.Empty;
            iconeID.BorderWidth = Unit.Empty; …
Run Code Online (Sandbox Code Playgroud)

c# csv arrays int parsing

0
推荐指数
1
解决办法
6840
查看次数

ASP.NET 2.0动态添加OnSelectedIndexChanged

我有一个 DropDownList() ,它在我的代码隐藏中呈现并由 myView 填充

 Dim ddl As New DropDownList()
 ddl.ID = "ddlV_" & dtrw("col_id") & "_" & fixDisplayName(dtrw("display_name"))
 ddl.DataSource = myView
 ddl.DataTextField = "DDLTEXT"
 ddl.DataValueField = "DDLVALUE"
 ddl.AutoPostBack="true"

 ddl.DataBind()
Run Code Online (Sandbox Code Playgroud)

我想OnSelectedIndexChanged ="do_this_when_changed"向上面的下拉列表添加属性。

我确实了解 Web 服务器控件也是在服务器上创建的,并且它们需要 runat="server" 属性才能工作。

这个列表控件可以这样做吗?

vb.net asp.net

0
推荐指数
1
解决办法
2032
查看次数

标签 统计

asp.net ×2

c# ×2

.net ×1

arrays ×1

c#-3.0 ×1

csv ×1

int ×1

parsing ×1

sql ×1

sql-server ×1

streamwriter ×1

string ×1

t-sql ×1

vb.net ×1

windows-7-x64 ×1

wsdl ×1