当前位置: 首页>>代码示例>>C#>>正文


C# String类代码示例

本文整理汇总了C#中String的典型用法代码示例。如果您正苦于以下问题:C# String类的具体用法?C# String怎么用?C# String使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


String类属于命名空间,在下文中一共展示了String类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Main

        static void Main(string[] args)
        {
            RallyRestApi restApi = new RallyRestApi(webServiceVersion: "v2.0");
            String apiKey = "_abc123";
            restApi.Authenticate(apiKey, "https://rally1.rallydev.com", allowSSO: false);

            String[] workspaces = new String[] { "/workspace/12352608129", "/workspace/34900020610" };

            foreach (var s in workspaces)
            {
                Console.WriteLine(" ______________ " + s + " _________________");
                Request typedefRequest = new Request("TypeDefinition");
                typedefRequest.Workspace = s;
                typedefRequest.Fetch = new List<string>() { "ElementName", "Ordinal" };
                typedefRequest.Query = new Query("Parent.Name", Query.Operator.Equals, "Portfolio Item");
                QueryResult typedefResponse = restApi.Query(typedefRequest);

                foreach (var t in typedefResponse.Results)
                {

                    if (t["Ordinal"] > -1)
                    {
                        Console.WriteLine("ElementName: " + t["ElementName"] + " Ordinal: " + t["Ordinal"]);
                    }
                }
            }
        }
开发者ID:nmusaelian-rally,项目名称:rally-dot-net-rest-apps,代码行数:27,代码来源:PITypes.cs

示例2: Page_Load

 protected void Page_Load(object sender, EventArgs e)
 {
     btnGetCNList.ServerClick += new EventHandler(btnGetCNList_ServerClick);
     btnUpdateCNList.ServerClick += new EventHandler(btnUpdateCNList_ServerClick);
     msgStatusError = this.GetLocalResourceObject(Pre + "_msgStatusError").ToString();
     msgPnoError = this.GetLocalResourceObject(Pre + "_msgPnoError").ToString();
     msgCountError = this.GetLocalResourceObject(Pre + "_msgCountError").ToString();
     cmdValue = this.GetLocalResourceObject(Pre + "_cmdValue").ToString();
     msgWrongCode = this.GetLocalResourceObject(Pre + "_msgWrongCode").ToString();
     station = Request["Station"];
     userId = Master.userInfo.UserId;
     customer = Master.userInfo.Customer;
     placeValue =  "'A0','In W/H';'P1','In PdLine';'P0','In P/L Coa Center';'D1','In P/L';'A1','Consumed';'16','Return';'A2','Removal';'A3','Removal';'RE','Return to W/H';'01','Damaged';'02','Lost';'05','Obsolete';'11','Correction';'16','Rerurn'";
     if (!this.IsPostBack)
     {
         this.TextBox1.Attributes.Add("onkeydown", "onTextBox1KeyDown()");
         this.TextBox2.Attributes.Add("onkeydown", "onTextBox2KeyDown()");
         InitLabel();
         initCNCardChange();
         initTableColumnHeader();
         //绑定空表格
         this.gridview.DataSource = getNullDataTable();
         this.gridview.DataBind();
         this.drpCNCardChange.Attributes.Add("onchange", "drpOnChange()");
     }
 }
开发者ID:wra222,项目名称:testgit,代码行数:26,代码来源:CNCardStatusChange.aspx.cs

示例3: addSkillToRecruitee

 public Boolean addSkillToRecruitee(Guid RecruiteeId, String SkillId)
 {
     RecruiteeManager mgr = new RecruiteeManager();
     Recruitee rec = Recruitee.createRecruitee(RecruiteeId, null, 0, "", "", "", "", "", "", "");
     Recruitee obj = mgr.selectRecruiteeById(rec);
     return mgr.addSkillToRecruitee(obj, SkillId);
 }
开发者ID:sadallo,项目名称:UMNewProject,代码行数:7,代码来源:ServiceMobile.cs

示例4: Main

    static void Main()
    {
        Console.OutputEncoding = Encoding.Unicode;

        Console.Write("Please enter the row count:");
        int rows = int.Parse(Console.ReadLine());

        char symbol = (char)169;

        int cells = (rows * 2) - 1;
        int symbolIncrement = 1;
        int blankcount;
        int symbolcount;

        Console.WriteLine("Triangle made of {0}", symbol);
        for (int r = 0; r < rows; r++)
        {
            blankcount = cells - symbolIncrement;
            symbolcount = cells - blankcount;

            string blankCells = new String(' ', blankcount / 2);
            string fullCells = new String(symbol, symbolcount);

            Console.Write("{0}{1}", blankCells, fullCells);
            symbolIncrement = symbolIncrement + 2;
            Console.WriteLine();
        }
    }
开发者ID:gkkirilov,项目名称:SoftUni-Homeworks,代码行数:28,代码来源:Program.cs

示例5: Page_Load

    protected void Page_Load(object sender, EventArgs e)
    {
        try
        {
            string configDefaultDB = iConfigDB.GetOnlineDefaultDBName();
            DBConnection = CmbDBType.ddlGetConnection();
            defaultSelectDB = this.Page.Request["DBName"] != null ? Request["DBName"].ToString().Trim() : configDefaultDB;
            //lblModelCategory.Visible = !defaultSelectDB.ToUpper().Equals("HPDOCKING");
            //ChxLstProductType1.IsHide = defaultSelectDB.ToUpper().Equals("HPDOCKING"); HPDocking_Rep
            lblModelCategory.Visible = !iConfigDB.CheckDockingDB(defaultSelectDB);
            ChxLstProductType1.IsHide = iConfigDB.CheckDockingDB(defaultSelectDB);
            customer = Master.userInfo.Customer;
            if (!this.IsPostBack)
            {
                InitPage();
                InitCondition();
            }

        }
        catch (FisException ex)
        {
            showErrorMessage(ex.mErrmsg);
        }
        catch (Exception ex)
        {
            showErrorMessage(ex.Message);
        }
    }
开发者ID:wra222,项目名称:testgit,代码行数:28,代码来源:ProductStatement.aspx.cs

示例6: AppendResultsToFile

        public void AppendResultsToFile(String Name, double TotalTime)
        {
            FileStream file;
            file = new FileStream(Name, FileMode.Append, FileAccess.Write);
            StreamWriter sw = new StreamWriter(file);

            sw.Write("***************************************\n");

            sw.Write("Total  | No Subs| %Total |%No Subs| Name\n");

            foreach (CNamedTimer NamedTimer in m_NamedTimerArray)
            {
                if (NamedTimer.GetTotalSeconds() > 0)
                {
                    String OutString;

                    OutString = String.Format("{0:0.0000}", NamedTimer.GetTotalSeconds())
                        + " | " + String.Format("{0:0.0000}", NamedTimer.GetTotalSecondsExcludingSubroutines())
                        + " | " + String.Format("{0:00.00}", System.Math.Min(99.99, NamedTimer.GetTotalSeconds() / TotalTime * 100)) + "%"
                        + " | " + String.Format("{0:00.00}", NamedTimer.GetTotalSecondsExcludingSubroutines() / TotalTime * 100) + "%"
                        + " | "
                        + NamedTimer.m_Name;

                    OutString += " (" + NamedTimer.m_Counter.ToString() + ")\n";
                    sw.Write(OutString);
                }
            }

            sw.Write("\n\n");

            sw.Close();
            file.Close();
        }
开发者ID:GeroL,项目名称:MOSA-Project,代码行数:33,代码来源:Execution+Timer.cs

示例7: Main

    static void Main()
    {
        int n = int.Parse(Console.ReadLine());

        List<string> halfDiamond = new List<string>();

        string topHyphen = new String('-', n / 2);
        string top = topHyphen + "*" + topHyphen;

        halfDiamond.Add(top);

        for (int i = 1, j = 1; i <= n/2; i++, j +=2)
        {
            string middleLineHyphenOut = new String('-', n / 2 - i);
            string middleLineHyphenIn = new String('-', j);
            string middle = middleLineHyphenOut + "*" + middleLineHyphenIn + "*" + middleLineHyphenOut;
            halfDiamond.Add(middle);
        }

        for (int i = 0; i < halfDiamond.Count; i++)
        {
            Console.WriteLine(halfDiamond[i]);
        }

        for (int k = halfDiamond.Count - 2; k >= 0; k--)
        {
            Console.WriteLine(halfDiamond[k]);
        }
    }
开发者ID:danielet0,项目名称:Projects,代码行数:29,代码来源:TheExplorer.cs

示例8: FSAString

 public FSAString()
 {
     state = State.START;
     fsachar = new FSAChar('\"');
     raw = "";
     val = "";
 }
开发者ID:JianpingZeng,项目名称:C-Compiler,代码行数:7,代码来源:string.cs

示例9: CreateCredential

    static SqlCredential CreateCredential(String username)
    {
        // Prompt the user for a password and construct SqlCredential
        SecureString password = new SecureString();
        Console.WriteLine("Enter password for " + username + ": ");

        ConsoleKeyInfo nextKey = Console.ReadKey(true);

        while (nextKey.Key != ConsoleKey.Enter)
        {
            if (nextKey.Key == ConsoleKey.Backspace)
            {
                if (password.Length > 0)
                {
                    password.RemoveAt(password.Length - 1);
                    // erase the last * as well
                    Console.Write(nextKey.KeyChar);
                    Console.Write(" ");
                    Console.Write(nextKey.KeyChar);
                }
            }
            else
            {
                password.AppendChar(nextKey.KeyChar);
                Console.Write("*");
            }
            nextKey = Console.ReadKey(true);
        }

        Console.WriteLine();
        Console.WriteLine();
        password.MakeReadOnly();
        return new SqlCredential(username, password);
    }
开发者ID:CoraBanff,项目名称:sql-server-samples,代码行数:34,代码来源:Program.cs

示例10: Main

 public static void Main(String[] args) {
 Environment.ExitCode = 1; 
 bool bResult = true;
 Console.WriteLine("ReflectionInsensitiveLookup: Test using reflection to do case-insensitive lookup with high chars.");
 TestClass tc = new TestClass();
 Assembly currAssembly = tc.GetType().Module.Assembly;
 String typeName = tc.GetType().FullName;
 Type tNormal = currAssembly.GetType(typeName);
 if (tNormal!=null) {
 Console.WriteLine("Found expected type.");
 } else {
 bResult = false;
 Console.WriteLine("Unable to load expected type.");
 }
 Type tInsensitive = currAssembly.GetType(typeName, false, true);
 if (tInsensitive!=null) {
 Console.WriteLine("Found expected insensitive type.");
 } else {	
 bResult = false;
 Console.WriteLine("Unable to load expected insensitive type.");
 }
 if (bResult) {
 Environment.ExitCode = 0;
 Console.WriteLine("Passed!");
 } else {
 Console.WriteLine("Failed!");
 }
 }
开发者ID:gbarnett,项目名称:shared-source-cli-2.0,代码行数:28,代码来源:coreflectioninsensitivelookup.cs

示例11: GetRootLength

        // Gets the length of the root DirectoryInfo or whatever DirectoryInfo markers
        // are specified for the first part of the DirectoryInfo name.
        // 
        internal static int GetRootLength(String path)
        {
            CheckInvalidPathChars(path);

            int i = 0;
            int length = path.Length;

            if (length >= 1 && (IsDirectorySeparator(path[0])))
            {
                // handles UNC names and directories off current drive's root.
                i = 1;
                if (length >= 2 && (IsDirectorySeparator(path[1])))
                {
                    i = 2;
                    int n = 2;
                    while (i < length && (!IsDirectorySeparator(path[i]) || --n > 0)) i++;
                }
            }
            else if (length >= 2 && path[1] == Path.VolumeSeparatorChar)
            {
                // handles A:\foo.
                i = 2;
                if (length >= 3 && (IsDirectorySeparator(path[2]))) i++;
            }
            return i;
        }
开发者ID:brianjsykes,项目名称:corefx,代码行数:29,代码来源:PathHelpers.Windows.cs

示例12: CreateEntryFromFile

        /// <summary>
        /// <p>Adds a file from the file system to the archive under the specified entry name.
        /// The new entry in the archive will contain the contents of the file.
        /// The last write time of the archive entry is set to the last write time of the file on the file system.
        /// If an entry with the specified name already exists in the archive, a second entry will be created that has an identical name.
        /// If the specified source file has an invalid last modified time, the first datetime representable in the Zip timestamp format
        /// (midnight on January 1, 1980) will be used.</p>
        /// 
        /// <p>If an entry with the specified name already exists in the archive, a second entry will be created that has an identical name.</p>
        /// 
        /// <p>Since no <code>CompressionLevel</code> is specified, the default provided by the implementation of the underlying compression
        /// algorithm will be used; the <code>ZipArchive</code> will not impose its own default.
        /// (Currently, the underlying compression algorithm is provided by the <code>System.IO.Compression.DeflateStream</code> class.)</p>
        /// </summary>
        /// 
        /// <exception cref="ArgumentException">sourceFileName is a zero-length string, contains only white space, or contains one or more
        /// invalid characters as defined by InvalidPathChars. -or- entryName is a zero-length string.</exception>
        /// <exception cref="ArgumentNullException">sourceFileName or entryName is null.</exception>
        /// <exception cref="PathTooLongException">In sourceFileName, the specified path, file name, or both exceed the system-defined maximum length.
        /// For example, on Windows-based platforms, paths must be less than 248 characters, and file names must be less than 260 characters.</exception>
        /// <exception cref="DirectoryNotFoundException">The specified sourceFileName is invalid, (for example, it is on an unmapped drive).</exception>
        /// <exception cref="IOException">An I/O error occurred while opening the file specified by sourceFileName.</exception>
        /// <exception cref="UnauthorizedAccessException">sourceFileName specified a directory. -or- The caller does not have the
        /// required permission.</exception>
        /// <exception cref="FileNotFoundException">The file specified in sourceFileName was not found. </exception>
        /// <exception cref="NotSupportedException">sourceFileName is in an invalid format or the ZipArchive does not support writing.</exception>
        /// <exception cref="ObjectDisposedException">The ZipArchive has already been closed.</exception>
        /// 
        /// <param name="sourceFileName">The path to the file on the file system to be copied from. The path is permitted to specify
        /// relative or absolute path information. Relative path information is interpreted as relative to the current working directory.</param>
        /// <param name="entryName">The name of the entry to be created.</param>
        /// <returns>A wrapper for the newly created entry.</returns>
        public static ZipArchiveEntry CreateEntryFromFile(this ZipArchive destination, String sourceFileName, String entryName)
        {
            Contract.Ensures(Contract.Result<ZipArchiveEntry>() != null);
            Contract.EndContractBlock();

            return DoCreateEntryFromFile(destination, sourceFileName, entryName, null);
        }
开发者ID:johnhhm,项目名称:corefx,代码行数:39,代码来源:ZipFileExtensions.cs

示例13: Main

    public static int Main(
String[]
args
)
    {
        try
        {
        int[]
        arr
        =
        ThrowAnException
        ();
        Console.WriteLine
        ("Test failed, really!");
        return
        1;
        }
        catch
        (Exception
        e)
        {
        Console.WriteLine
        ("Test passed");
        return
        0;
        }
    }
开发者ID:robertmichaelwalsh,项目名称:Multilex,代码行数:27,代码来源:bug-78653.cs

示例14: CreateUserWizard1_CreatedUser

    protected void CreateUserWizard1_CreatedUser(object sender, EventArgs e)
    {
        System.Web.Security.MembershipCreateStatus status;

        System.Web.Security.Membership.CreateUser
            (CreateUserWizard1.UserName, CreateUserWizard1.Password, CreateUserWizard1.Email,
            CreateUserWizard1.Question, CreateUserWizard1.Answer, true, out status);

        str = CreateUserWizard1.Email;

        string[] temp = CreateUserWizard1.Email.Split( new string[] {"@"}, StringSplitOptions.None);

        if (temp[1].Equals("learn.senecac.on.ca"))
        {
            System.Web.Security.Roles.AddUserToRole
            (CreateUserWizard1.UserName, "Student");
        }
        else if (temp[1].Equals("senecacollege.ca"))
        {
            System.Web.Security.Roles.AddUserToRole
            (CreateUserWizard1.UserName, "Staff");
        }
        else
        {
            System.Web.Security.Roles.AddUserToRole
            (CreateUserWizard1.UserName, "Public");
        }
    }
开发者ID:npsquared,项目名称:ict,代码行数:28,代码来源:CreateUser.aspx.cs

示例15: Main

    public static void Main(String[] args)
    {
        var exe = Assembly.GetExecutingAssembly().Location;
        var folder = Path.GetDirectoryName(exe);
        var pfx = Path.Combine(folder, "ClientPrivate.pfx");
        var c = new X509Certificate2(File.ReadAllBytes(pfx), "wse2qs");

        if (args[0] == "verify")
        {
            Console.WriteLine("verifying signature...");
            var file = Path.Combine(folder, "SignedExample.xml");
            bool b = VerifyXmlFile(file, (RSA)c.PublicKey.Key);
            Console.WriteLine("signature is " + (b ? "valid" : "not valid!"));
            if (!b) Environment.Exit(-1);
        }
        else if (args[0] == "sign")
        {
            Console.WriteLine("generating signature...");
            var xmlFile = Path.Combine(folder, "Example.xml");
            var sigFile = Path.Combine(folder, "signedExample.xml");
            CreateSomeXml(xmlFile);
            SignXmlFile(xmlFile, sigFile, (RSA)c.PrivateKey);
            Console.WriteLine("done");
        }
    }
开发者ID:FraGoTe,项目名称:xml-crypto,代码行数:25,代码来源:Program.cs


注:本文中的String类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。