Home » C#

C# | Uri.GetLeftPart() Method with Example

Uri.GetLeftPart() Method: Here, we are going to learn about the GetLeftPart() method of Uri class with example in C#.
Submitted by Nidhi, on March 26, 2020

Uri.GetLeftPart() Method

Uri.GetLeftPart() method is an instance method that is used to get a specified part from the given URI based on passed UriPartial enum.

Syntax:

    string Uri.GetLeftPart (UriPartial Part);

Parameter(s):

  • Part – represents UriPartial to get specified part from Uri.

Return value:

The return type of this method is string, it returns string value to represent specified part of Uri.

Exception:

    System.ArgumentException;
    System.InvalidOperationException;

Example to demonstrate example of Uri.GetLeftPart() method

using System;

class UriExample
{
    //Entry point of Program
    static public void Main()
    {
        // Create an object of Uri
        Uri Address;

        Address = new Uri("https://www.includehelp.com/index.html#search");

        Console.WriteLine(Address.GetLeftPart(UriPartial.Authority));
        Console.WriteLine(Address.GetLeftPart(UriPartial.Path));
        Console.WriteLine(Address.GetLeftPart(UriPartial.Query));
        Console.WriteLine(Address.GetLeftPart(UriPartial.Scheme));
    }
}

Output

https://www.includehelp.com
https://www.includehelp.com/index.html
https://www.includehelp.com/index.html
https://





Comments and Discussions

Ad: Are you a blogger? Join our Blogging forum.





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.