If we assume we have this little snippet of code:

string str = "checked";
bool test1;

if (str == "checked")
{
    test1 = true;
}
else
{
    test1 = false;
}


Is it bad practice to change a simple statement like this to the following?:

bool test2 = (str == "checked");


Because they work exactly the same, and work as required, so I can't imagine how it would be. However, as a young, inexperienced programmer I am not aware of whether such a thing is frowned upon or not. Can anyone tell me, if this is NOT ok, why not?

The following test program:

using System;

public class Test
{

    public static void Main()
    {
        string str = "checked";

        bool test1;

        if (str == "checked")
        {
            test1 = true;
        }
        else
        {
            test1 = false;
        }

        bool test2 = (str == "checked");

        bool test3 = (str != "checked");

        Console.WriteLine(test1.ToString());
        Console.WriteLine(test2.ToString());
        Console.WriteLine(test3.ToString());
    }
}


Outputs:

True
True
False


Any insight etc is appreciated.


Question: Computer browsing not working
Answer: DNS doesn't facilitate network browsing. NetBIOS facilitates network browsing.

Network browsing has never been "reliable" in the sense that the list of computers is always accurate and complete.

If you want to have an accurate and complete list of computers while browsing the network then you'll have to implement a WINS server.

Personally, I don't understand why this is an issue. Why is it important that users be able to browse an accurate and complete list of computers on the network? Do they not know where resources are (shared folders and printers) and need to browse the network to find them? If so, that's poor infrastructure design and management, IMO.