IMG

 
IMG
IMG   IMG
  Welcome to GTAForums! Be sure to check out the Grand Theft Auto V Forum.

You are not registered! (If you are, click here to login) Registering is fast, free and easy and allows you to instantly reply to any topic on GTAForums.
Why wait? Click here to register your own unique username and become part of the ever-growing community!


( Log In | Register | Revalidate Validation E-mail )
Quick Log-In:
  IMG
       
>
  Reply to this topicStart new topicStart Poll

 Questions about C#

 
Bad.boy!  
Posted: Monday, Apr 9 2012, 21:47
Quote Post


SA modder
Group Icon
Group: Members
Joined: Jun 20, 2010

nl.gif

XXXXX



Does anyone know how to make global strings in C#? I know you can make something like this:
CODE
public static class Globals
   {
       public const string FCarcol = "example";
   }


But that doesn't allow me to write something new.

And how to break up a string like this in seperate parts:
CODE
supergt, supergt, car,  SUPERGT,  SUPER,  VEH@LOW, VEH@LOW_INFERNUS, 100, 999,  0.2286, 0.2286,  0, 2, 1.0 ,0, -


This post has been edited by Bad.boy! on Tuesday, Apr 10 2012, 08:47
PM
  Top
 

 
nightwalker83  
Posted: Tuesday, Apr 10 2012, 00:33
Quote Post


Don't mind me
Group Icon
Group: Members
Joined: Oct 10, 2004

au.gif

XXXXX



Question like this should be in the modding section I will request it moved.
Users WebsitePMMSN
  Top
 

 
Bad.boy!  
Posted: Tuesday, Apr 10 2012, 08:19
Quote Post


SA modder
Group Icon
Group: Members
Joined: Jun 20, 2010

nl.gif

XXXXX



But it isn't a GTA mod. It's a windows console aplication. And my questions have nothing to do with GTA modding.
QUOTE
Does anyone know how to make global strings in C#?
And how to break up a string like this in seperate parts:


EDIT:
Found it btw
CODE
public static class Globals
   {
       public static string FCarcol
       {
           get
           {
               return FCarcol;
           }
           set
           {
               FCarcol = value;
           }
       }

       public static string FHandling
       {
           get
           {
               return FHandling;
           }
           set
           {
               FHandling = value;
           }
       }

       public static string FVehicle
       {
           get
           {
               return FVehicle;
           }
           set
           {
               FVehicle = value;
           }
       }
   }


CODE
string FCarcol = Globals.FCarcol;
           string FHandling = Globals.FHandling;
           string FVehicle = Globals.FVehicle;
           string[] Cline = Regex.Split(FCarcol, " ");


This post has been edited by Bad.boy! on Tuesday, Apr 10 2012, 08:47
PM
  Top
 

 
Barguast  
Posted: Tuesday, Apr 10 2012, 23:20
Quote Post


Thy next foe is...
Group Icon
Group: Moderators
Joined: Jul 27, 2002

uk.gif

Member Award




Those properties call themselves. You'll get stack overflows. A simple global string can be declared with;

public static string Str;

Or

public static string Str { get; set; }

Also, you can use string.Split rather than the RegEx method.

(on my phone, so sorry for bad formatting)
PM
  Top
 

 
Bad.boy!  
Posted: Wednesday, Apr 11 2012, 17:22
Quote Post


SA modder
Group Icon
Group: Members
Joined: Jun 20, 2010

nl.gif

XXXXX



Thanks for the help.

Do you also happen to know how to enter the location of a file, because when I type C:/Users for example the code can't find the location (as a string).

Nevermind

This post has been edited by Bad.boy! on Wednesday, Apr 11 2012, 18:49
PM
  Top
 

 
vincelegard  
Posted: Sunday, Jun 24 2012, 18:07
Quote Post


Player Hater
Group Icon
Group: Members
Joined: Jun 24, 2012

XXXXX



split function


//declare a string array
string[] strArr = null;

str = "upergt, supergt, car, SUPERGT, SUPER, VEH@LOW, VEH@LOW_INFERNUS, 100, 999, 0.2286, 0.2286, 0, 2, 1.0 ,0, -"
char[] splitchar = { ',' };
strArr = str.Split(splitchar);

from strArr you can retrieve each string

source : http://csharp.net-informations.com/string/...tring-split.htm

legard.
PM
  Top
 

 

1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)

0 Members:

Topic Options Reply to this topicStart new topicStart Poll
Search topic for posted by (exact match)



 
IMG IMG