×

C# Tutorial

Basics of .Net

C# Basics

C# Fundamentals

C# Operators

C# Loops

C# Type Conversions

C# Exception Handling

C# String Class

C# Arrays

C# List

C# Stack

C# Queue

C# Collections

C# Character Class

C# Class and Object

C# Namespaces

C# Delegates

C# Constructors

C# Inheritance

C# Operator Overloading

C# Structures

C# File Handling

C# Convert.ToInt32()

C# Int32 (int) Struct

C# DateTime Class

C# Uri Class

C# Database Connectivity

C# Windows

C# Other Topics

C# Q & A

C# Programs

C# Find O/P

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


Comments and Discussions!

Load comments ↻


Advertisement
Advertisement
Advertisement

Copyright © 2025 www.includehelp.com. All rights reserved.