Uri.IsLoopback Property in C# with Example
Last Updated :
08 Jun, 2020
Uri.IsLoopback Property is property of Uri class which used to check that the specified Uri references the local host.
Syntax:
public bool IsLoopback { get; }
Return Value: The return type of this property is Boolean, if this Uri references the local host it returns true otherwise it returns false.
Exception: This property will give InvalidOperationException if this instances represents a relative Uri as this property is only applicable for the absolute URI’s.
Example 1:
C#
using System;
using System.Globalization;
class GFG {
public static void Main()
{
bool status = v1.IsLoopback;
if (status)
Console.WriteLine( "Given Uri is a reference of localhost" );
else
Console.WriteLine( "Given Uri is not reference of localhost" );
}
}
|
Output:
Given Uri is not reference of localhost
Example 2:
C#
using System;
using System.Globalization;
class GFG {
public static void Main()
{
bool status = v1.IsLoopback;
if (status)
Console.WriteLine( "Given Uri is a reference of localhost" );
else
Console.WriteLine( "Given Uri is not reference of localhost" );
}
}
|
Output:
Given Uri is a reference of localhost
Share your thoughts in the comments
Please Login to comment...