Invalid expression term 'out'

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • slsv
    New Member
    • Apr 2013
    • 14

    Invalid expression term 'out'

    Hi, I'm a little bit new in this area and I have this error
    Can someone tell me what is this mean? -
    Invalid expression term 'out' and
    Identifier expected; 'out' is a keyword

    Code:
    public static void userDell(string msi,String filename, String DB_CONN_STRING)
            {
                String temp_msisdn = "+" + msi;
                bool ima = DatabaseConnection.checkExist(temp_msi);
                bool result;
                if (ima) 
                {
                    result = DatabaseConnection.deleteRoute(temp_msi);
                }
                System.out.println ("Delete Route " + temp_msi);
                WriteLog.writeLog(filename + "|OK|DELETE|" + temp_msi + "||" + "route deleted||\n", "logs", "1.log");
            }
  • r035198x
    MVP
    • Sep 2006
    • 13225

    #2
    That line
    Code:
    System.out.println ("Delete Route " + temp_msi);
    , did you get that ffrom some Java code somewhere? In C# you use Console.WriteLi ne instead.

    Comment

    • slsv
      New Member
      • Apr 2013
      • 14

      #3
      Yes, is part of Java code.
      I saw that in Java System.out.prin tln is equivalent to Console.WriteLi ne in C#.. but when i change it i get more errors.. like:
      Code:
      bool ima = DatabaseConnection.checkExist(temp_msisdn);
      'DatabaseConnec tion' does not exist in current context.
      Code:
      WriteLog.writeLog(...)
      'WriteLog' does not exist in current context.

      When is a 'System.out.pri ntln' i don't have this errors..

      Comment

      • r035198x
        MVP
        • Sep 2006
        • 13225

        #4
        Those errors are there because you didn't import the namespaces that contain those classes. The System.out.prin tln doesn't fix those errors, it just hides them. Don't try to compile Java code using a C# compiler. Write proper C# code importing the required classes with the using clause.

        Comment

        • slsv
          New Member
          • Apr 2013
          • 14

          #5
          Like I said, I'm a little bit new and I don't know exactly how to rewrite it in C#..
          That's why i trying to work with this java piece of code..
          I must do this piece of code in my first post to make it work in this condition. How can :
          Code:
              string[] lines = File.ReadAllLines(@"pathtofile"); 
                      foreach (string line in lines)
                      {
                          string[] columns = line.Split('|');
                          string code = columns[2];
                          if (code.Equals("D"))
                          {
                              mod.userDell);
                              Console.WriteLine("");
                          }
          Basically read one file and when the flag is "D" must delete from DB

          Comment

          • r035198x
            MVP
            • Sep 2006
            • 13225

            #6
            If you need to write C# code then read a C# tutorial first. You can't just copy code from one language to another without understanding the syntax rules of the target language first.

            Comment

            • slsv
              New Member
              • Apr 2013
              • 14

              #7
              Ok, thanks for the help.

              Comment

              • vijay6
                New Member
                • Mar 2010
                • 158

                #8
                Hey slsv, till now what did you done with your code? Did you read your file? Did you connected to your database from your C# Program? If connected means, did you checked whether user is already existed or not in your table?

                Comment

                • slsv
                  New Member
                  • Apr 2013
                  • 14

                  #9
                  Hey vijya6, till now i successfully connected to database and read from file. So now i need to perform this action in my first post. While i read the file i check for flag "D" and when i have a line with this file I must delete.

                  Comment

                  • vijay6
                    New Member
                    • Mar 2010
                    • 158

                    #10
                    While i read the file i check for flag "D" and when i have a line with this file I must delete.
                    Hey slsv, what you want to delete?

                    Comment

                    • slsv
                      New Member
                      • Apr 2013
                      • 14

                      #11
                      Whole line and continue to next line.

                      Comment

                      • vijay6
                        New Member
                        • Mar 2010
                        • 158

                        #12
                        Whole line and continue to next line.
                        Hey slsv, you want to remove whole line only from your file?

                        Comment

                        • slsv
                          New Member
                          • Apr 2013
                          • 14

                          #13
                          it's only one file.. here is the scenario:
                          1.Connect and take the file.
                          2.Read the file and split it.
                          3.While reading the file if the char of this line is "d" i will delete the line and continue on next.

                          So far i have connection and reading.
                          I have this what to do if flag is 'D' ( first post ) then in my reading class i put this:
                          Code:
                          UserMod.UserMod mod = new UserMod.UserMod();
                          How to call it in here:
                          Code:
                          if (code.Equals("D"))
                                          {
                                              mod.userDell( // HERE ); <--- HERE 
                                              Console.WriteLine("");
                                          }

                          Comment

                          • vijay6
                            New Member
                            • Mar 2010
                            • 158

                            #14
                            Hey slsv, try this code...

                            Code:
                            string text = String.Empty;
                            
                            string[] lines = System.IO.File.ReadAllLines(@"pathtofile");
                            foreach (string line in lines)
                            {
                            	string[] columns = line.Split('|');
                            	string code = columns[2];
                            	if (!code.Equals("D"))
                            	{
                            		text = text + line + Environment.NewLine;
                            	}
                            }
                            
                            text = text.Remove(text.Length - 1);
                            
                            System.IO.File.WriteAllText(@"pathtofile", text);

                            Comment

                            • slsv
                              New Member
                              • Apr 2013
                              • 14

                              #15
                              Hey, thanks for this but how this is connected with this
                              Code:
                                  public static void userDell(string msi,String filename, String DB_CONN_STRING)
                                          {
                                              String temp_msisdn = "+" + msi;
                                              bool ima = DatabaseConnection.checkExist(temp_msi);
                                              bool result;
                                              if (ima) 
                                              {
                                                  result = DatabaseConnection.deleteRoute(temp_msi);
                                              }
                                              System.out.println ("Delete Route " + temp_msi);
                                              WriteLog.writeLog(filename + "|OK|DELETE|" + temp_msi + "||" + "route deleted||\n", "logs", "1.log");
                                          }
                              I want to use this?

                              Comment

                              Working...