ADVERTISEMENT
ADVERTISEMENT

VB.Net program to generate the sequence that contains one repeated value

Here, we are going to learn how to generate the sequence that contains one repeated value in VB.Net?
Submitted by Nidhi, on February 02, 2021

In this program, we will use the Repeat() method of the Enumerable class to generate the sequence that contains one repeated value.

Program/Source Code:

The source code to generate the sequence that contains one repeated value is given below. The given program is compiled and executed successfully.

'VB.NET program to generate the sequence 
'that contains one repeated value.

Module Module1
    Sub Main()
        Dim intValues = Enumerable.Repeat(Of Integer)(786, 5)
        Dim strValues = Enumerable.Repeat(Of String)("India", 5)

        Console.WriteLine("Repeated integer elements:")
        For i = 0 To intValues.Count() - 1 Step 1
            Console.Write(intValues.ElementAt(i) & " ")
        Next
        Console.WriteLine()

        Console.WriteLine("Repeated string elements:")
        For i = 0 To strValues.Count() - 1 Step 1
            Console.Write(strValues.ElementAt(i) & " ")
        Next
        Console.WriteLine()
    End Sub
End Module

Output:

Sequence of elements:
Repeated integer elements:
786 786 786 786 786
Repeated string elements:
India India India India India
Press any key to continue . . .

Explanation:

In the above program, we created a module Module1 that contains a Main() function. The Main() function is the entry point for the program.

In the Main() function, We generated the sequence that contains one repeated value using the Repeat() method of Enumerable class and prints those elements on the console screen.

VB.Net LINQ Query Programs »



ADVERTISEMENT



ADVERTISEMENT



Comments and Discussions


ADVERTISEMENT

ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT

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.