Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Trimming blanks from a Parameter
Message
From
23/06/2010 09:20:44
 
General information
Forum:
ASP.NET
Category:
Coding, syntax and commands
Environment versions
Environment:
C# 3.0
Miscellaneous
Thread ID:
01470305
Message ID:
01470314
Views:
40
>>Hi,
>>
>>I'm drawing a blank on how to do this. I am passing a parameter into a method and wish to trim any blanks from the parameter.
>>
>>This is my code:
>>
>>
        private void SetClientTypeDisplay(string clientType)
>>        {
>>            if (clientType.Trim() == "Company")
>>            {
>>                this.pnlCompany.Visible = true;
>>
>>But I get a runtime error: "Object reference not set to an object instance."
>>
>>What's the correct syntax to do this?
>
>It just sounds like clientType may be null in some cases. Maybe just change the code to something like this:
>
>
>if (clientType != null && clientType.Trim() == "Company")
>
>
>>

Hi Paul,

thanks, but no, clientType is never null.
Frank.

Frank Cazabon
Samaan Systems Ltd.
www.samaansystems.com
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform