Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6912853
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T09:08:37+00:00 2026-05-27T09:08:37+00:00

Which of these methods are the most efficient one or is there a better

  • 0

Which of these methods are the most efficient one or is there a better way to do it?

this.returnList[i].Title[0].ToString()

or

this.returnList[i].Title.Substring(0, 1)
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T09:08:38+00:00Added an answer on May 27, 2026 at 9:08 am

    They’re both very fast:

    Char Index

    var sample = "sample";
    var clock = new Stopwatch();
    for (var i = 0; i < 10; i++)
    {
        clock.Start();
        for (var j = 0; j < 10000000; j++)
        {
            var first = sample[0].ToString();
        }
        clock.Stop();
        Console.Write(clock.Elapsed);
        clock.Reset();
    }
    
    // Results
    00:00:00.2012243
    00:00:00.2207168
    00:00:00.2184807
    00:00:00.2258847
    00:00:00.2296456
    00:00:00.2261465
    00:00:00.2120131
    00:00:00.2221702
    00:00:00.2346083
    00:00:00.2330840
    

    Substring

    var sample = "sample";
    var clock = new Stopwatch();
    for (var i = 0; i < 10; i++)
    {
        clock.Start();
        for (var j = 0; j < 10000000; j++)
        {
            var first = sample.Substring(0, 1);
        }
        clock.Stop();
        Console.Write(clock.Elapsed);
        clock.Reset();
    }
    
    // Results
    00:00:00.3268155
    00:00:00.3337077
    00:00:00.3439908
    00:00:00.3273090
    00:00:00.3380794
    00:00:00.3400650
    00:00:00.3280275
    00:00:00.3333719
    00:00:00.3295982
    00:00:00.3368425
    

    I also agree with BrokenGlass that using the char index is a cleaner way of writing it. Plus if you’re doing it 10 trillion times it’ll be much faster!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Just wondering if this is the most efficient method of doing this? is there
I don't know which of those three methods suits me most. They all work
I have a class called Path for which there are defined about 10 methods,
There are numerous Agile software development methods. Which ones have you used in practice
Of the two methods below, which do you prefer to read? Is there another
There are too many method for embedding flash in html, which way is the
I'm trying to decide what the most efficient way to render a bunch of
What is the most efficient way of reading just part of the binary data
I'm looking for some ideas on how to do this in the most efficient
My question is what is the best and most efficient way to save a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.