• Register

Recent questions tagged c#

0 votes
1 answer 3 views
Problem: I have been learning C# and got an assignment in which I have to read a string as input from a user and then check if it contains a digit or not. If it contains a digit, a bool variable must be set to true, or else it must remain false. After this, a validity ... of the bool variable. I have no idea how I can do this task. If any of you could help, that would be a great pleasure. Thanks!
asked 20 hours ago Sheeza 3.9k points
0 votes
1 answer 5 views
I was working on that. I just want to know how to do that?
asked 21 hours ago TeamScript 3k points
0 votes
1 answer 4 views
Problem: Hello Programmers, I am a noob and just came to know about the loop constructs in C#. I tried running while and do-while loops in a program and got different output. Following are the programs that I executed: //Program 1 int a = 0; do { Console.WriteLine( ... ; } Console.ReadKey(); The output has confused me and I want to know the major difference in the while and do-while loops. Thanks!
asked 2 days ago Sheeza 3.9k points
0 votes
1 answer 5 views
Problem: Hello! I tried running following program: class Program { static void Main(string[] args) { int x = 9; while (x++ < 10) Console.WriteLine(x); Console.ReadKey(); } } The output that I assumed was nothing but a blank screen because x++ = 9 ... 10 I am unable to understand the output. I want to know how that output was generated and in what manner the conditions and operators are evaluated.
asked 3 days ago Sheeza 3.9k points
0 votes
1 answer 4 views
Problem: Hi there! I am new to the world of programming and learning loop constructs in C#. My concept for loops is clear but I just recently encountered a code somewhere in which for loop was initialized as follows: for(;;) { } I tried running that code, but it ... I make some mistake but I want to know more about &lsquo;for&rsquo; loops and all the possible ways in which it can be used. Thanks!
asked 3 days ago Sheeza 3.9k points
0 votes
1 answer 3 views
Problem: Hi there! I am newbie and I am want to strip away specific characters from the end of a string. I am programming in C#. I have tried Remove() method as follows: using System; namespace ConsoleApp2 { class Program { static void Main(string[] args) { ... the index of string myself. I want to know that is there any way in C# to remove characters from strings without specifying the index?
asked 4 days ago Sheeza 3.9k points
0 votes
1 answer 3 views
Problem I would like understand the difference between ASP.NET Core and, so called, ordinary ASP.NET. I have significant experience programming ASP.NET and I had an opportunity to take a look on ASP.NET Core project and it feels like completely different creature.
asked 4 days ago alexh 1.6k points
0 votes
1 answer 4 views
Problem: Hi there! I am new to the world of programming. My programming teacher gave me an assignment in which I have to write a program in which there would be a function that will take two strings as input from user and will compare the size of both strings ... the larger string of the two. I have no clue how to do that. Please provide me with the sample program with proper description. Thanks
asked 5 days ago Sheeza 3.9k points
0 votes
1 answer 3 views
Problem: Hi there! I am working with enumerations in C# and I am trying to check whether certain string exists in my enumeration or not. I am using &lsquo;if&rsquo; condition with == operator but the compiler is giving some error and I am not getting the desired output. How can I convert a string to enumeration in order to check whether it exists in enum or not?
asked Nov 24 Sheeza 3.9k points
0 votes
1 answer 6 views
Problem: Hi there! I have been working in C# since last month and have learned a lot of things. I have written many console programs for converting one type of data to another. Recently, my teacher gave me an assignment in which I have to convert an Image to byte array. I ... with images yet and I have no idea how can I complete the task. If any of you could help me, I would be grateful thanks.
asked Nov 23 Sheeza 3.9k points
0 votes
1 answer 10 views
Problem I never have developed multithreading applications before, so I am a bit confused how to make one thread to wait for another. In general, I have UI thread and 2 other threads, which do some processing. I need the processing to be executed in different thread (not the UI one) in ... Task t2 = Task.Factory.StartNew(new Action(() => { //Do another stuff here })); } How can I sync t1 and t2?
asked Nov 19 alexh 1.6k points
0 votes
1 answer 6 views
Problem I am confused by properties access modifiers. When declare set accessor of the property as private I know it restricts access to the property assignment, it allows to set value only from the class methods. But how can I initialize it or assign to any value? What for ... So why does it exist in C# ,when should I use it and how should I populate these properties from outside of the class ?
asked Nov 18 alexh 1.6k points
0 votes
1 answer 11 views
Problem: Hi there! I am trying to convert an integer number to a byte array using following snippet: static void Main(string[] args) { int i = 44; byte[] b = Convert.ToByte(i); //Error foreach (byte byt in b) Console.WriteLine(byt); Console.ReadKey(); ... says &ldquo;Cannot implicitly convert byte to byte[]&rdquo;. Does anybody have any idea why this error is occuring and how can I resolve it?
asked Nov 18 Sheeza 3.9k points
0 votes
1 answer 10 views
Problem: Hello programmers! I am a newbie in the world of programming and I am working with dictionaries in C#. I want to check whether a key exists in Dictionary or not. If the key does not exist I want my program to automatically add the key to the dictionary. I have tried many ways but nothing works. I would be glad if any of you could help me. Thanks!
asked Nov 18 Sheeza 3.9k points
0 votes
1 answer 3 views
Problem: Hi programmers! I am trying to store the index of the elements in an enumeration in an integer variable but I am facing some issue that says &ldquo;cannot implicitly convert types&rdquo;. My question is that how can I achieve what I am trying to do?? If someone could explain in easy words, that would be appreciable. Thanks.
asked Nov 17 Sheeza 3.9k points
0 votes
1 answer 11 views
Problem: Hi there! I am working with arrays and I am trying to delete the element at index 4 using RemoveAt() method. This method is not working with arrays and I am facing an error that says: &ldquo;no definition for RemoveAt() exists&hellip;&hellip;.&rdquo;. What should I do? Why is this error occurring? Please guide if I am doing something wrong.
asked Nov 15 Sheeza 3.9k points
0 votes
1 answer 13 views
Problem: Hello developer, I have seen the following line of code to check if a string contains certain characters or not. static void Main(string[] args) { string s = "Thermometer"; bool str = s.Contains("meter", StringComparison.OrdinalIgnoreCase); Console.WriteLine(str); ... it was. Please tell me what is the problem with my code and explain if there is any alternative way to do so. Thanks!
asked Nov 14 Sheeza 3.9k points
0 votes
1 answer 14 views
Problem: Hi there! I am a beginner and I just read about System.Reflection class recently. I came to know that I can use it to convert one object to another as per requirement. I want to know more about it and how can I use Reflection class to get the value of a property?
asked Nov 14 Sheeza 3.9k points
0 votes
1 answer 8 views
Problem What is the difference between interfaces and abstract classes? When should I use interface and when abstract class? Does exist any rule of thumb or decision tree for that?
asked Nov 14 alexh 1.6k points
0 votes
1 answer 18 views
Problem I have a form with textbox, the user types a value, which I need to process as string. What is the best way to do this? var age = txtAge.Text;
asked Nov 11 alexh 1.6k points