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 7683459
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T18:47:55+00:00 2026-05-31T18:47:55+00:00

I have strings formatted using the code below String.Format({0,-10} {1,10}, Kills:, kills); String.Format({0,-10} {1,10},

  • 0

I have strings formatted using the code below

String.Format("{0,-10} {1,10}", "Kills:", kills);
String.Format("{0,-10} {1,10}", "Points:", points);
String.Format("{0,-10} {1,10}", "$:", currency);

From what I understood, the first part of the strings should be left justified with a 10 space buffer and then the integer variables should be printed right justified with a 10 space buffer.

However when attempt to draw the strings using SpriteBatch.DrawString, nothing aligns properly.

The left aligned side prints properly, but the right aligned side centres on a certain point, for example if kills = 50 and points = 5002, the 50 will be centered over the 00 in the 5002…

What is going on?

  • 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-31T18:47:57+00:00Added an answer on May 31, 2026 at 6:47 pm

    Quite simply, I suspect you’re not using a monospaced font. When different characters have different widths, you can’t use spaces to line things up. (Your sample works when using Console.WriteLine for example, as the console has a fixed width font by default.)

    You’ll either have to use a monospaced font, or you’ll have to draw the strings separately – draw each string to fit the relevant area. I don’t know anything about XNA, but I’d expect you to either have to measure the width of the string before you draw it (so you can subtract it from the right-hand edge, for example) or specify some sort of layout value which indicates “right-align this string with a particular point”.

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

Sidebar

Related Questions

I have a formatted string from a log file, which looks like: >>> a=test
I have strings that are formatted as below: Houston, TX - str1 Chicago, IL
i have existing code that generates a spreadsheet from excel using OpenXML. It works
I'm using HTTP Get to retrieve a JSON formatted String from my website. However,
Suppose I have a large number of strings formatted something like: <tag>blah blahXXXXXblah blah</tag>
I have a task of parsing a simple XML-formatted string in a MySQL stored
I want to have a PHP script send a XML formatted string to another
So I have a flashobject which I need to pass a formatted DateTime string
I have a problem that output string must be utf8-formatted, I am writing currently
I have a bunch of records with dates formatted as a string such as

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.