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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T19:48:24+00:00 2026-05-24T19:48:24+00:00

I have created a small program to write XML-Comment for Properties(which dont have customer

  • 0

I have created a small program to write XML-Comment for Properties(which dont have customer attributes applied).

    /// <summary>
    /// Write XML-Comment for Properties(which dont have customer attributes applied).
    /// </summary>
    /// <param name="fileName">'*.cs' file along with full path to comment.</param>
    /// <returns></returns>
    static bool WriteComment(string fileName)
    {
        List<string> code = new List<string>();

        using (StreamReader sr = new StreamReader(fileName))
        {

            while (!sr.EndOfStream)
            {
                code.Add(sr.ReadLine());
            }

            List<int> indexes = (from line in code
                                 where line.Contains("get")
                                 select code.IndexOf(line)).ToList();

            int count = 0;
            foreach (int i in indexes)
            {
                code.Insert((i + count++) - 2, getWhiteSpace(code[(i + count) - 3]) + "/// <summary>");
                code.Insert((i + count++) - 2, getWhiteSpace(code[(i + count) - 3]) + "/// Gets or Sets the " + getPropertyName(code[(i + count) - 3]));
                code.Insert((i + count++) - 2, getWhiteSpace(code[(i + count) - 3]) + "/// </summary>");
            }
        }

#if DEBUG
        foreach (string line in code)
            Console.WriteLine(line);
#else
        using (StreamWriter sw = new StreamWriter(fileName))
        {
            foreach (string line in code)
                sw.WriteLine(line);
        }
#endif

        return true;
    }

    /// <summary>
    /// To retrive property name.
    /// </summary>
    /// <param name="property">Property Name Line(line with visibiliy mode and return type ).</param>
    /// <returns>Property Name.</returns>
    public static string getPropertyName(string property)
    {
        return Regex.Replace(property.Substring(property.LastIndexOf(" ")), "([a-z])([A-Z])", "$1 $2").TrimStart();
    }

    /// <summary>
    /// Get initial position of the property. So that XML-comment can be placed properly 
    /// at the top.
    /// </summary>
    /// <param name="codeLine">Property Line code.</param>
    /// <returns>Number of White Space.</returns>
    public static string getWhiteSpace(string codeLine)
    {
        string retStr = "";
        foreach (string s in codeLine.Split())
        {
            if (s != string.Empty) break;
            retStr += " ";
        }
        return retStr;
    }

As you can see on the method getWhiteSpace I’m checking for Empty String and it works well. But, if I apply string.Empty to retStr on loop…the returned value will be string.Empty only! This I can understand that concatenating the string.Empty will result string.Empty only.

Now my question is how if (s != string.Empty) is working and why if (s != " ") or if (s != "\t") is not working?

  • 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-24T19:48:25+00:00Added an answer on May 24, 2026 at 7:48 pm

    If you are on .NET 4.0, have a look at String.IsNullOrWhiteSpace()

    if(s != string.Empty) break;
    if(s != "") break;
    

    are essentially the same.
    this should tell you why

    if(s != " ") break;

    is not working. It is because "" is not equal to " ".
    the same is true for "\t": it is not equal to either " " or ""


    Update:
    I figure you’re trying to get the number of whitespaces at the beginning of each line in order to correctly indent the auto generated comments.
    I’d probably go about this as follows:

    EDIT: removed own code. Instead take a look here:

    Get leading whitespace

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

Sidebar

Related Questions

I have created a small program which logs text data to a file on
I have created a small application which opens,reads and creates Excel files. The app
I want to globalize my application. I have created a small form which asks
I have created a small Java application in which there is some code that
I have created a small flash CS4 project that has a few custom components
I have created a few small flash widgets that stream .mp3 audio from an
I have a program that creates a small file in the Bin directory for
I have an assignment about fftw and I was trying to write a small
I have to frequently compile small program and run it. Since, it was tedious
I have created small socket programs (client/server). Client will transfer all formats of files

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.