Click here to Skip to main content
15,434,301 members
Home / Discussions / C#
   

C#

 
AnswerRe: C# Set voice in Text to Speech Pin
OriginalGriff27-Jul-22 20:16
mveOriginalGriff27-Jul-22 20:16 
GeneralRe: C# Set voice in Text to Speech Pin
Rockallica28-Jul-22 8:39
MemberRockallica28-Jul-22 8:39 
GeneralRe: C# Set voice in Text to Speech Pin
OriginalGriff28-Jul-22 8:52
mveOriginalGriff28-Jul-22 8:52 
QuestionIn C# can't introduce a formula in Excel Pin
Ismael_199927-Jul-22 12:37
MemberIsmael_199927-Jul-22 12:37 
AnswerRe: In C# can't introduce a formula in Excel Pin
trønderen27-Jul-22 12:55
Membertrønderen27-Jul-22 12:55 
AnswerRe: In C# can't introduce a formula in Excel Pin
Gerry Schmitz27-Jul-22 14:47
mveGerry Schmitz27-Jul-22 14:47 
GeneralRe: In C# can't introduce a formula in Excel Pin
Ismael_199928-Jul-22 7:53
MemberIsmael_199928-Jul-22 7:53 
QuestionI having this error could anyone can help me :Unhandled Exception: System.NullReferenceException: Object reference not set to an instance of an object at ValidParenthese.Solution.IsValid (System.String s) [0x00000] in <89120c6f256647e6a05011f274f6a Pin
swethamaddi26-Jul-22 23:20
Memberswethamaddi26-Jul-22 23:20 
using System;
using System.Collections.Generic;
using System.Linq;

namespace ValidParenthese {

    public class Solution {
        public bool IsValid(string s) {
            var result = s.ToCharArray().ToList();
            bool value = true;

            for (int i = 0; i < result.Count; i++) {

                if (result[i].ToString().Equals("(")) {

                    if (result[i + 1].ToString().Equals(")")) {
                        value = true;
                    } else {
                        var count = result.Count;

                        if (count >= 3) {

                            var index = result[i + 1];

                            if (result[i + 2].ToString().Equals(")")) {
                                value = false;
                            } else if ((index.ToString().Equals("{") && result[i + 2].ToString().Equals("}"))
                                || (index.ToString().Equals("[") && result[i + 2].ToString().Equals("]"))) {

                                if (result[i + 3].ToString().Equals(")")) {
                                    value = true;
                                } else {
                                    var ind = result[i + 2];

                                    if ((ind.ToString().Equals("{") && result[i + 3].ToString().Equals("}"))
                                        || (ind.ToString().Equals("[") && result[i + 3].ToString().Equals("]"))) {

                                        if ((index.ToString().Equals("{") && result[i + 4].ToString().Equals("}"))
                                            || (index.ToString().Equals("[") && result[i + 4].ToString().Equals("]"))) {
                                            if (result[i + 5].ToString().Equals(")")) {
                                                value = true;
                                            } else {
                                                value = false;
                                            }
                                        } else {
                                            value = false;
                                        }
                                    } else {
                                        value = false;
                                    }
                                }
                            }

                        } else {
                            value = false;
                        }


                    }

                } else if (result[i].ToString().Equals("{")) {

                    if (result[i + 1].ToString().Equals("}")) {
                        value = true;
                    } else {
                        var count = result.Count;

                        if (count >= 3) {

                            var index = result[i + 1];

                            if (result[i + 2].ToString().Equals("}")) {
                                value = false;
                            } else if ((index.ToString().Equals("(") && result[i + 2].ToString().Equals(")"))
                                || (index.ToString().Equals("[") && result[i + 2].ToString().Equals("]"))) {

                                if (result[i + 3].ToString().Equals("}")) {
                                    value = true;
                                } else {
                                    var ind = result[i + 2];

                                    if ((ind.ToString().Equals("(") && result[i + 3].ToString().Equals(")"))
                                        || (ind.ToString().Equals("[") && result[i + 3].ToString().Equals("]"))) {

                                        if ((index.ToString().Equals("(") && result[i + 4].ToString().Equals(")"))
                                            || (index.ToString().Equals("[") && result[i + 4].ToString().Equals("]"))) {
                                            if (result[i + 5].ToString().Equals("}")) {
                                                value = true;
                                            } else {
                                                value = false;
                                            }
                                        } else {
                                            value = false;
                                        }
                                    } else {
                                        value = false;
                                    }
                                }
                            }

                        } else {
                            value = false;
                        }


                    }

                } else if (result[i].ToString().Equals("[")) {

                    if (result[i + 1].ToString().Equals("]")) {
                        value = true;
                    } else {
                        var count = result.Count;

                        if (count >= 3) {

                            var index = result[i + 1];

                            if (result[i + 2].ToString().Equals("]")) {
                                value = false;
                            } else if ((index.ToString().Equals("(") && result[i + 2].ToString().Equals(")"))
                                || (index.ToString().Equals("{") && result[i + 2].ToString().Equals("}"))) {

                                if (result[i + 3].ToString().Equals("]")) {
                                    value = true;
                                } else {
                                    var ind = result[i + 2];

                                    if ((ind.ToString().Equals("(") && result[i + 3].ToString().Equals(")"))
                                        || (ind.ToString().Equals("{") && result[i + 3].ToString().Equals("}"))) {

                                        if ((index.ToString().Equals("(") && result[i + 4].ToString().Equals(")"))
                                            || (index.ToString().Equals("{") && result[i + 4].ToString().Equals("}"))) {
                                            if (result[i + 5].ToString().Equals("]")) {
                                                value = true;
                                            } else {
                                                value = false;
                                            }
                                        } else {
                                            value = false;
                                        }
                                    } else {
                                        value = false;
                                    }
                                }
                            }

                        } else {
                            value = false;
                        }


                    }

                } else {

                }
            }

            return value;
        }
    }

    class ValidParentheses {
        public static void Main(string[] args) {
            var solution = new Solution();

            if (solution.IsValid(Console.ReadLine())) {
                Console.WriteLine("valid");
            } else {
                Console.WriteLine("invalid");
            }
        }
    }
}

AnswerRe: I having this error could anyone can help me :Unhandled Exception: System.NullReferenceException: Object reference not set to an instance of an object at ValidParenthese.Solution.IsValid (System.String s) [0x00000] in <89120c6f256647e6a05011f27 Pin
Richard MacCutchan26-Jul-22 23:51
mveRichard MacCutchan26-Jul-22 23:51 
AnswerRe: I having this error could anyone can help me :Unhandled Exception: System.NullReferenceException: Object reference not set to an instance of an object at ValidParenthese.Solution.IsValid (System.String s) [0x00000] in <89120c6f256647e6a05011f27 Pin
Dave Kreskowiak27-Jul-22 6:57
mveDave Kreskowiak27-Jul-22 6:57 
QuestionWhat Is NullReferenceException? Object reference not set to an instance of an object i have error how to change code unable to excute below code could help me Pin
swethamaddi26-Jul-22 23:15
Memberswethamaddi26-Jul-22 23:15 
AnswerRe: What Is NullReferenceException? Object reference not set to an instance of an object i have error how to change code unable to excute below code could help me Pin
Richard MacCutchan26-Jul-22 23:51
mveRichard MacCutchan26-Jul-22 23:51 
AnswerRe: What Is NullReferenceException? Object reference not set to an instance of an object i have error how to change code unable to excute below code could help me Pin
OriginalGriff27-Jul-22 0:04
mveOriginalGriff27-Jul-22 0:04 
AnswerRe: What Is NullReferenceException? Object reference not set to an instance of an object i have error how to change code unable to excute below code could help me Pin
Calin Cali28-Jul-22 0:11
MemberCalin Cali28-Jul-22 0:11 
QuestionHow to convert pdf file into FileStream? Pin
Code4Ever26-Jul-22 6:35
MemberCode4Ever26-Jul-22 6:35 
GeneralRe: How to convert pdf file into FileStream? Pin
Richard MacCutchan26-Jul-22 6:49
mveRichard MacCutchan26-Jul-22 6:49 
GeneralRe: How to convert pdf file into FileStream? Pin
Code4Ever26-Jul-22 6:59
MemberCode4Ever26-Jul-22 6:59 
GeneralRe: How to convert pdf file into FileStream? Pin
Richard Deeming26-Jul-22 22:03
mveRichard Deeming26-Jul-22 22:03 
GeneralRe: How to convert pdf file into FileStream? Pin
Code4Ever28-Jul-22 19:52
MemberCode4Ever28-Jul-22 19:52 
AnswerRe: How to convert pdf file into FileStream? Pin
Dave Kreskowiak26-Jul-22 7:24
mveDave Kreskowiak26-Jul-22 7:24 
GeneralRe: How to convert pdf file into FileStream? Pin
Code4Ever26-Jul-22 7:39
MemberCode4Ever26-Jul-22 7:39 
GeneralRe: How to convert pdf file into FileStream? Pin
Dave Kreskowiak26-Jul-22 7:45
mveDave Kreskowiak26-Jul-22 7:45 
QuestionTechnic or best way to know if an application is "ready" when it is started from another application ? Pin
Maximilien25-Jul-22 1:14
MemberMaximilien25-Jul-22 1:14 
AnswerRe: Technic or best way to know if an application is "ready" when it is started from another application ? Pin
Richard MacCutchan25-Jul-22 3:08
mveRichard MacCutchan25-Jul-22 3:08 
AnswerRe: Technic or best way to know if an application is "ready" when it is started from another application ? Pin
Gerry Schmitz27-Jul-22 6:43
mveGerry Schmitz27-Jul-22 6:43 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.