C-Sharp | Java | Python | Swift | GO | WPF | Ruby | Scala | F# | JavaScript | SQL | PHP | Angular | HTML
Then: The method will determine if the case-sensitive strings "Net", "Codex", or "Dot" are located in the string.
And: Because it is called twice, we can test the Contains method's correctness.
VB.NET program that uses Contains method
Module Module1
Sub Main()
' Call the Test sub with different string literal arguments.
Test("The Dev Codes")
Test("dot net Codex")
End Sub
Sub Test(ByVal input As String)
' Write the formal parameter.
Console.Write("--- ")
Console.Write(input)
Console.WriteLine(" ---")
' See if it contains this string.
Dim net As Boolean = input.Contains("Net")
Console.Write("Contains 'Net': ")
Console.WriteLine(net)
' See if it contains this string.
If input.Contains("Codex") Then
Console.WriteLine("Contains 'Codex'")
End If
' See if it does not contain this string.
If Not input.Contains("Dot") Then
Console.WriteLine("Doesn't Contain 'Dot'")
End If
End Sub
End Module
Output
--- The Dev Codes ---
Contains 'Net': True
--- dot net Codex ---
Contains 'Net': False
Contains 'Codex'
Doesn't Contain 'Dot'
Note: For more details on string searching, please check out the IndexOf method.
IndexOf