Function to look for null string and return a space if found

I have an XSLT file and inside I have a function that needs to return a space if the value is NULL. However, it is complaining about the line below specifically which is if (string A == ""). Would anyone know what is wrong with that?

    public string TermDate(string A)
        if (string A == "")
            return " ";
            return A;                                                 




Do not use string key word in if condition part.


if (string A=="")


if (A=="")

You can read more about the syntax of if here.

if (String.IsNullOrEmpty(A)) return " ";
else return A;

Couple more options (using String.IsNullOrEmpty ) in addition to normal if(a)...:

? : - conditional operator:

return String.IsNullOrEmpty(a) ? " " : a;

?? - null coalescing operator:

return a ?? " ";

Need Your Help

Simple bind to a class in a WPF app

wpf class data-binding

How do I take a basic class that I've made and extract it's properties in the list in WPF? I've already tried playing with the itemssource property but nothing seems to have worked for me.

How to push from one branch to another and checkout?


I am trying to implement the setup outlined here but with one difference. On my local repository I want to use a branch different to master.

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.