Home » C#

C# | Uri.IsLoopback Property with Example

Uri.IsLoopback Property: Here, we are going to learn about the IsLoopback Property of Uri class with example in C#.
Submitted by Nidhi, on March 28, 2020

Uri.IsLoopback Property

Uri.IsLoopback Property is instance property of Uri class which used to check that specified Uri is the reference of localhost/loopback or not. This property returns a boolean value. If specified Uri is the reference of localhost/loopback then it returns true otherwise it returns false. This property may generate System.InvalidOperationException exception.

Syntax:

    public bool IsLoopback { get; }

Return value:

The return type of this property is Boolean, it returns a Boolean value that is true if this Uri references the local host; otherwise, false.

Example to demonstrate example of Uri.IsLoopback Property

using System;

class UriExample
{
    //Entry point of Program
    static public void Main()
    {
        Uri domainUri;
        Uri domainUri1;

        domainUri = new Uri("https://www.includehelp.com:8082");
        domainUri1 = new Uri("http://localhost");

        if (domainUri.IsLoopback)
            Console.WriteLine("Given Uri is a reference of localhost");
        else
            Console.WriteLine("Given Uri is a not reference of localhost");


        if (domainUri1.IsLoopback)
            Console.WriteLine("Given Uri is a reference of localhost");
        else
            Console.WriteLine("Given Uri is a not reference of localhost");
    }
}

Output

Given Uri is a not reference of localhost
Given Uri is a reference of localhost

In the above program we created an object of Uri class initialized with website name with port number and here we checked given Uri is a reference of localhost/loopback using IsLoopback property of Uri class.

Reference: Uri.IsLoopback Property

ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT


Comments and Discussions!




Languages: » C » C++ » C++ STL » Java » Data Structure » C#.Net » Android » Kotlin » SQL
Web Technologies: » PHP » Python » JavaScript » CSS » Ajax » Node.js » Web programming/HTML
Solved programs: » C » C++ » DS » Java » C#
Aptitude que. & ans.: » C » C++ » Java » DBMS
Interview que. & ans.: » C » Embedded C » Java » SEO » HR
CS Subjects: » CS Basics » O.S. » Networks » DBMS » Embedded Systems » Cloud Computing
» Machine learning » CS Organizations » Linux » DOS
More: » Articles » Puzzles » News/Updates

© https://www.includehelp.com some rights reserved.