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

  • SEARCH
  • Home
  • 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 7047425
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T02:46:11+00:00 2026-05-28T02:46:11+00:00

I have problem with my code. I don’t know what am I doing wrong.

  • 0

I have problem with my code. I don’t know what am I doing wrong. I want for user to write some sentence and then program should split written sentence into single words where I use ToUpper on first chars of each word in array and then join the together again without spaces.

my code is:

    static void Skrci(string stavek)
    {
        string[] p;
        p = stavek.Split(' ');  // polje separatov

        for (int i = 0; i < p.Length; i++)
        {
            if (p[i].Length > 0)
            {
                char zacetnica = Char.ToUpper(p[i][0]);
                p[i] = p[i].Remove(0, 1);
                p[i] = p[i].Insert(0, zacetnica.ToString());
            }
        }
        stavek = string.Join(" ", p);
    }

    static void Main(string[] args)
    {
        string[] p = null;
        Console.Write("Vpiši nek stavek: ");
        string stavek = Console.ReadLine();
        Skrci(stavek);
        Console.WriteLine(stavek);
        Console.ReadKey(true);
    }

I tried Step into to see if I can see what is wrong but I don’t know.

  • 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-28T02:46:12+00:00Added an answer on May 28, 2026 at 2:46 am

    You should pass your string to function as a reference, not as a value. Use ref keyword for that.

    Example:

    static void Skrci(ref string stavek)
        {
            string[] p;
            p = stavek.Split(' ');  // polje separatov
    
            for (int i = 0; i < p.Length; i++)
            {
                if (p[i].Length > 0)
                {
                    char zacetnica = Char.ToUpper(p[i][0]);
                    p[i] = p[i].Remove(0, 1);
                    p[i] = p[i].Insert(0, zacetnica.ToString());
                }
            }
            stavek = string.Join(" ", p);
        }
    
        static void Main(string[] args)
        {
            string[] p = null;
            Console.Write("Vpiši nek stavek: ");
            string stavek = Console.ReadLine();
            Skrci(ref stavek);
            Console.WriteLine(stavek);
            Console.ReadKey(true);
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

  There is some problem code in a website I don't have source access
I have problem compilin this code..can anyone tell whats wrong with the syntax CREATE
I have problem with this code: file = tempfile.TemporaryFile(mode='wrb') file.write(base64.b64decode(data)) file.flush() os.fsync(file) # file.seek(0)
Possible Duplicate: What's wrong with Delphi's “with” I am have a problem debugging code
I have some problem with my code public IQueryable<PageItems> GetPageById(Guid Id) { var xml
I have a problem with this piece of code If I don't use the
I have a problem in my code which i can't understand. I want to
I have problem with h:datatable tag in JSF. I don't know, why my datatable
I have a little problem, in my source code I don't see why is
I have a problem and don't really know where to look for the cause

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.