Click here to Skip to main content
15,911,786 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
how do i create a c# visual studio graphic program to count the number of vowels in strings ,assigning each vowel for thread in? my fonction sould be void excute .but loop should return a's example string <b>

What I have tried:

for loop with lenght string
the problem is in the void function of the thread
Posted
Updated 8-Dec-20 19:24pm
v2
Comments
The Other John Ingram 8-Dec-20 19:11pm    
how about showing us your code.
Patrice T 8-Dec-20 19:13pm    
First part of question is corrupted.
Show your code.

This may (or may not) help:

How do I find duplicates in an char array[^]
 
Share this answer
 
There are a lot of ways - some of these may be interesting to you: Counting Lines in a String[^]

Threads have a void signature because when they come to an end they are killed, and that releases the stack memory they were assigned. Since the stack is no longer there, there is no way to return a value via the usual return keyword!

Instead, your thread must communicate it's result back to the calling thread in a different way, and that will depend on how you start your threads.
If you use a BackgroundWorker class, then that helps you out a lot - it provides an Event the main thread had handle when the thread ends which provides a Result property in the EventArgs that teh main thread can read: BackgroundWorker Class (System.ComponentModel) | Microsoft Docs[^] - the link includes sample code.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900