Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

PadLeft

Posted on 2004-10-15
13
Medium Priority
?
208 Views
Last Modified: 2010-04-23
In c# I have the code as follows:
reqn = Session["Reqnumber"].ToString();
reqn = reqn.PadLeft(15,'-');
The value of reqn is never right justified. Please help me.
Thanks
0
Comment
Question by:miyengar
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 7
  • 4
  • 2
13 Comments
 
LVL 28

Expert Comment

by:iboutchkine
ID: 12322307
I thiink you have to assign it to different variable
dim a as string
a= reqn.PadLeft(15,'-');
regn = a
0
 
LVL 86

Expert Comment

by:Mike Tomlinson
ID: 12322557
This worked for me in VB.Net (notice the double quotation marks):

    Dim reqn As String = "something"
    reqn = reqn.PadLeft(15, "-")
    MsgBox(reqn)

~IM
0
 

Author Comment

by:miyengar
ID: 12322708
It does not work. any other soln
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 

Author Comment

by:miyengar
ID: 12323284
reqn = Session["Reqnumber"].ToString();
a = reqn.PadLeft(15,'-');
It returns the value of a as null. Please tell me why?
0
 
LVL 28

Accepted Solution

by:
iboutchkine earned 100 total points
ID: 12323306
Did you check your session value?
0
 

Author Comment

by:miyengar
ID: 12323434
my session value and reqn contains the actual value "wq-01".but "a" still has null
0
 

Author Comment

by:miyengar
ID: 12323496
It does not work properly i have my code as follows:
                           
            private void Page_Load(object sender, System.EventArgs e)
            {
                  
                       string r;
                  string reqn;
                  string rqtextid;
                  reqn = Session["Reqnumber"].ToString();
                  r = reqn.PadLeft(9,'.');
                  rqtextid = r;
my session value has valid value iii0, reqn also has the same value iii0. but r has null.
0
 
LVL 86

Expert Comment

by:Mike Tomlinson
ID: 12323883
Did you actually try it with double quotes?

    r = reqn.PadLeft(9,".");
0
 

Author Comment

by:miyengar
ID: 12337965
using double quotes gives me an error as no overload method as it accepts int and char.
0
 
LVL 86

Expert Comment

by:Mike Tomlinson
ID: 12338715
How odd...it works in VB.Net.  Thought it was supposed to be a "common" language runtime...

~IM
0
 

Author Comment

by:miyengar
ID: 12338827
any other suggestion please
I have the code as
  private void Page_Load(object sender, System.EventArgs e)
          {
               
                     string r;
               string reqn;
               string rqtextid;
               reqn = Session["Reqnumber"].ToString();
               r = reqn.PadLeft(9,'.');
               rqtextid = r;

in the above code r has ----wq001 but in the statement rqtextid  = r, rqtextid  has null.
Please help.
0
 
LVL 86

Expert Comment

by:Mike Tomlinson
ID: 12339300
Have you tried going directly to rqtextid?

    rqtextid = Session["Reqnumber"].ToString().PadLeft(9,'.');

~IM
0
 

Author Comment

by:miyengar
ID: 12339807
I did.  If I have to add text further after rightjustifying it would display null
for ex:
rqtextid = Session["Reqnumber"].ToString().PadLeft(9,'.');
rqtextid += "kkk";
would return rqtextid as null
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Video by: ITPro.TV
In this episode Don builds upon the troubleshooting techniques by demonstrating how to properly monitor a vSphere deployment to detect problems before they occur. He begins the show using tools found within the vSphere suite as ends the show demonst…
Are you ready to place your question in front of subject-matter experts for more timely responses? With the release of Priority Question, Premium Members, Team Accounts and Qualified Experts can now identify the emergent level of their issue, signal…
Suggested Courses

636 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question