Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
S

swethamaddi

@swethamaddi
About
Posts
2
Topics
2
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • 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 <89120c6f256647e6a05011f274f6a
    S swethamaddi

    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\[
    
    C# help csharp database linq

  • 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
    S swethamaddi

    using System;
    using System.Collections.Generic;

    namespace CalPoints {
    class Solution {
    public int CalPoints(string[] ops) {
    var opsList = new List();
    var value = 0;

            foreach (var item in ops) {
    
                if (item.Equals("+")) {
    
                    var index = int.Parse(opsList\[opsList.Count - 1\]) + int.Parse(opsList\[opsList.Count - 2\]);
                    opsList.Add(index.ToString());
    
                    value = 0;
    
                    foreach (var val in opsList) {
                        value += int.Parse(val);
                    }
    
                } else if (item.Equals("D")) {
    
                    var index = int.Parse(opsList\[opsList.Count - 1\]) \* 2;
                    opsList.Add(index.ToString());
    
                    value = 0;
    
                    foreach (var val in opsList) {
                        value += int.Parse(val);
                    }
    
                } else if (item.Equals("C")) {
    
                    opsList.RemoveAt(opsList.Count - 1);
    
                    value = 0;
    
                    foreach (var val in opsList) {
                        value += int.Parse(val);
                    }
    
                } else {
                    //An integer was added
                    opsList.Add(item);
    
                    foreach (var val in opsList) {
                        value += int.Parse(val);
                    }
                }
    
            }
    
            return value;
        }
    }
    
    class CalPoints {
        public static void Main(string\[\] args) {
            var solution = new Solution();
            var space = new char\[\] { ' ' };
    
            string\[\] ops = Console.ReadLine().Split(space);
            int output = solution.CalPoints(ops);
            Console.Write(output.ToString());
        }
    }
    

    }

    C# help question database tutorial
  • Login

  • Don't have an account? Register

  • Login or register to search.
  • First post
    Last post
0
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups