Solved

PadLeft

Posted on 2004-10-15
13
186 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
  • 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 85

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
Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

 

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 50 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 85

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 85

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 85

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

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Getting multiple values from a dataset ASP.NET(VB) 3 50
DataGridView Events ? 3 45
Help with LINQ and XML 10 36
send messages to whatsapp programatically 2 48
I think the Typed DataTable and Typed DataSet are very good options when working with data, but I don't like auto-generated code. First, I create an Abstract Class for my DataTables Common Code.  This class Inherits from DataTable. Also, it can …
Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.

777 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