C Sharp Online Compiler
Write, Run & Share C# code online using OneCompiler’s C# online compiler for free. It’s one of the robust, feature-rich online compilers for C# language, running on the latest version 8.0. Getting started with the OneCompiler’s C# compiler is simple and pretty fast. The editor shows sample boilerplate code when you choose language as C#
and start coding.
Read inputs from stdin
OneCompiler’s C# online compiler supports stdin and users can give inputs to programs using the STDIN textbox under the I/O tab. Following is a sample program which takes name as input and print your name with hello.
using System;
namespace Sample
{
class Test
{
public static void Main(string[] args)
{
string name;
name = Console.ReadLine();
Console.WriteLine("Hello {0} ", name);
}
}
}
About C Sharp
C# is a general purpose object-oriented programming language by Microsoft. Though initially it was developed as part of .net but later it was approved by ECMA and ISO standards.
You can use C# to create variety of applications, like web, windows, mobile, console applications and much more using Visual studio.
Syntax help
Data types
Data Type | Description | Range | size |
---|---|---|---|
int | To store integers | -2,147,483,648 to 2,147,483,647 | 4 bytes |
double | to store large floating point numbers with decimals | can store 15 decimal digits | 8 bytes |
float | to store floating point numbers with decimals | can store upto 7 decimal digits | 4 bytes |
char | to store single characters | — | 2 bytes |
string | to stores text | — | 2 bytes per character |
bool | to stores either true or false | — | 1 bit |
Variables
Syntax
datatype variable-name = value;
Loops
1. If-Else:
When ever you want to perform a set of operations based on a condition or set of few conditions IF-ELSE is used.
if(conditional-expression) {
// code
}
else {
// code
}
You can also use if-else for nested Ifs and If-Else-If ladder when multiple conditions are to be performed on a single variable.
2. Switch:
Switch is an alternative to If-Else-If ladder.
switch(conditional-expression) {
case value1:
// code
break; // optional
case value2:
// code
break; // optional
...
default:
// code to be executed when all the above cases are not matched;
}
3. For:
For loop is used to iterate a set of statements based on a condition.
for(Initialization; Condition; Increment/decrement) {
// code
}
4. While:
While is also used to iterate a set of statements based on a condition. Usually while is preferred when number of iterations are not known in advance.
while(condition) {
// code
}
5. Do-While:
Do-while is also used to iterate a set of statements based on a condition. It is mostly used when you need to execute the statements atleast once.
do {
// code
} while (condition);
Arrays
Array is a collection of similar data which is stored in continuous memory addresses. Array values can be fetched using index. Index starts from 0 to size-1.
Syntax
data-type[] array-name;
Methods
Method is a set of statements which gets executed only when they are called. Call the method name in the main function to execute the method.
Syntax
static void method-name()
{
// code to be executed
}
View attachment 175598 c:UsersCHRISTIANDocumentsMy GamesTerrariaModLoaderMod SourcesKraZe’s ModKraZe’s Mod.cs(3,16) : error CS1010: Newline in constant
c:UsersCHRISTIANDocumentsMy GamesTerrariaModLoaderMod SourcesKraZe’s ModKraZe’s Mod.cs(3,16) : error CS1012: Too many characters in character literal
c:UsersCHRISTIANDocumentsMy GamesTerrariaModLoaderMod SourcesKraZe’s ModKraZe’s Mod.cs(5,13) : error CS1010: Newline in constant
c:UsersCHRISTIANDocumentsMy GamesTerrariaModLoaderMod SourcesKraZe’s ModKraZe’s Mod.cs(5,13) : error CS1012: Too many characters in character literal
c:UsersCHRISTIANDocumentsMy GamesTerrariaModLoaderMod SourcesKraZe’s ModKraZe’s Mod.cs(7,15) : error CS1010: Newline in constant
c:UsersCHRISTIANDocumentsMy GamesTerrariaModLoaderMod SourcesKraZe’s ModKraZe’s Mod.cs(7,15) : error CS1012: Too many characters in character literal
c:UsersCHRISTIANDocumentsMy GamesTerrariaModLoaderMod SourcesKraZe’s ModKraZe’s Mod.cs(3,16) : error CS1514: { expected
c:UsersCHRISTIANDocumentsMy GamesTerrariaModLoaderMod SourcesKraZe’s ModKraZe’s Mod.cs(5,13) : error CS1514: { expected
c:UsersCHRISTIANDocumentsMy GamesTerrariaModLoaderMod SourcesKraZe’s ModKraZe’s Mod.cs(5,13) : error CS1519: Invalid token »u0073» in class, struct, or interface member declaration
c:UsersCHRISTIANDocumentsMy GamesTerrariaModLoaderMod SourcesKraZe’s ModKraZe’s Mod.cs(7,15) : error CS1519: Invalid token »u0073» in class, struct, or interface member declaration
c:UsersCHRISTIANDocumentsMy GamesTerrariaModLoaderMod SourcesKraZe’s ModKraZe’s Mod.cs(9,15) : error CS1519: Invalid token ‘=’ in class, struct, or interface member declaration
c:UsersCHRISTIANDocumentsMy GamesTerrariaModLoaderMod SourcesKraZe’s ModKraZe’s Mod.cs(9,21) : error CS1520: Method must have a return type
c:UsersCHRISTIANDocumentsMy GamesTerrariaModLoaderMod SourcesKraZe’s ModKraZe’s Mod.cs(14,5) : error CS1597: Semicolon after method or accessor block is not valid
c:UsersCHRISTIANDocumentsMy GamesTerrariaModLoaderMod SourcesKraZe’s ModKraZe’s Mod.cs(17,1) : error CS1022: Type or namespace definition, or end-of-file expected
c:UsersCHRISTIANDocumentsMy GamesTerrariaModLoaderMod SourcesKraZe’s ModItemsSlime Sword.cs(4,16) : error CS1010: Newline in constant
c:UsersCHRISTIANDocumentsMy GamesTerrariaModLoaderMod SourcesKraZe’s ModItemsSlime Sword.cs(4,16) : error CS1012: Too many characters in character literal
c:UsersCHRISTIANDocumentsMy GamesTerrariaModLoaderMod SourcesKraZe’s ModItemsSlime Sword.cs(4,16) : error CS1514: { expected
c:UsersCHRISTIANDocumentsMy GamesTerrariaModLoaderMod SourcesKraZe’s ModItemsSlime Sword.cs(6,21) : error CS1514: { expected
c:UsersCHRISTIANDocumentsMy GamesTerrariaModLoaderMod SourcesKraZe’s ModItemsSlime Sword.cs(6,27) : error CS1519: Invalid token ‘:’ in class, struct, or interface member declaration
c:UsersCHRISTIANDocumentsMy GamesTerrariaModLoaderMod SourcesKraZe’s ModItemsSlime Sword.cs(7,2) : error CS1519: Invalid token ‘{‘ in class, struct, or interface member declaration
How do I fix this???
-
Question
-
Hello,
Am new to this programming am using c# with ninja trader programming language. I have the 4 file but main file contains the namespace and class setdefulats ,on barupdate method .
Remaining and all just created under the main class namspace.
* my problem is 1.cs file doesnt have any error but2.cs file having the error cs0118 ,cs1519,cs1003 like invalid toke ; in class ,struct or interface,classmemberdeclaratione expected and ; expected these arethe error occured.
* butthe 2.cs file uses generic and linq also with lamda expressione if i change any thing . itwillbe error like the namespace alredy exists but using as ctypeand ninjascript assenbly reference missing.
the code will
protected void DisposeUnmanagedGraphics() { BuyLadderBrushDx?.Dispose(); BuyLadderBrushDx = null; SellLadderBrushDx?.Dispose(); SellLadderBrushDx = null; PositiveDeltaBrushDx?.Dispose(); PositiveDeltaBrushDx = null; NegativeDeltaBrushDx?.Dispose(); NegativeDeltaBrushDx = null; ChartBackgroundBrushDx?.Dispose(); ChartBackgroundBrushDx = null; }
be here. in this code am getting error like expressione expected the above code in 1.cs file main one
#region Properties // Profile [Display(Name = "Mode", GroupName = "01. Profile", Order = 0)] public ProfileMode ProfileMode { get; set; } = ProfileMode.Volume; [Display(Name = "Show Delta", GroupName = "01. Profile", Order = 1)] public bool ShowDelta { get; set; } = false; [Range(0, 100), NinjaScriptProperty] [Display(Name = "Value Area, %", GroupName = "01. Profile", Order = 2)] public double VAPercentage { get; set; } = 68; [Display(Name = "POC mode", GroupName = "01. Profile", Order = 3)] public LevelMode POCMode { get; set; } = LevelMode.On; [Display(Name = "POC", GroupName = "01. Profile", Order = 4)] public Stroke POCStroke { get; set; } = new Stroke(Brushes.DarkOrange); [Display(Name = "VAH/VAL mode", GroupName = "01. Profile", Order = 5)] public LevelMode VAHVALMode { get; set; } = LevelMode.On; [Display(Name = "VAH/VAL", GroupName = "01. Profile", Order = 6)] public Stroke VAHVALStroke { get; set; } = new Stroke(Brushes.Gray); [Display(Name = "VWAP mode", GroupName = "01. Profile", Order = 8)] public VWAPMode VWAPMode { get; set; } = VWAPMode.DynamicStdDev2; [Display(Name = "VWAP", GroupName = "01. Profile", Order = 9)] public Stroke VWAPStroke { get; set; } = new Stroke(Brushes.LightBlue, DashStyleHelper.Dash, 2); [Display(Name = "Sigma 1", GroupName = "01. Profile", Order = 10)] [Range(1, 100), NinjaScriptProperty] public int Sigma1 { get; set; } = 1; [Display(Name = "Standard deviation 1", GroupName = "01. Profile", Order = 11)] public Stroke Deviation1Stroke { get; set; } = new Stroke(Brushes.RoyalBlue, 1); [Display(Name = "Sigma 2", GroupName = "01. Profile", Order = 12)] [Range(1, 100), NinjaScriptProperty] public int Sigma2 { get; set; } = 2; [Display(Name = "Standard deviation 2", GroupName = "01. Profile", Order = 13)] public Stroke Deviation2Stroke { get; set; } = new Stroke(Brushes.Brown, 1); // --- [Range(1, 100), NinjaScriptProperty] [Display(Name = "Width, %", GroupName = "01. Profile", Order = 14)] public float ProfileWidthPercentage { get; set; } = 60; [Display(Name = "Position", GroupName = "01. Profile", Order = 15)] public ProfilePosition ProfilePosition { get; set; } = ProfilePosition.Left; [XmlIgnore] [Display(Name = "Color", GroupName = "01. Profile", Order = 16)] public System.Windows.Media.Brush LadderBrush { get; set; } = Brushes.Gray; [Browsable(false)] public string LadderBrushSerializable { get { return Serialize.BrushToString(LadderBrush); } set { LadderBrush = Serialize.StringToBrush(value); } } [XmlIgnore] [Display(Name = "VA color", GroupName = "01. Profile", Order = 17)] public System.Windows.Media.Brush VALadderBrush { get; set; } = Brushes.LightGray; [Browsable(false)] public string VALadderBrushSerializable { get { return Serialize.BrushToString(VALadderBrush); } set { VALadderBrush = Serialize.StringToBrush(value); } } [XmlIgnore] [Display(Name = "Buy", GroupName = "01. Profile", Order = 20)] public System.Windows.Media.Brush BuyLadderBrush { get; set; } = Brushes.LightGreen; [Browsable(false)] public string BuyLadderBrushSerializable { get { return Serialize.BrushToString(BuyLadderBrush); } set { BuyLadderBrush = Serialize.StringToBrush(value); } } [XmlIgnore] [Display(Name = "Sell", GroupName = "01. Profile", Order = 21)] public System.Windows.Media.Brush SellLadderBrush { get; set; } = Brushes.Red; [Browsable(false)] public string SellLadderBrushSerializable { get { return Serialize.BrushToString(SellLadderBrush); } set { SellLadderBrush = Serialize.StringToBrush(value); } } [XmlIgnore] [Display(Name = "Positive Delta", GroupName = "01. Profile", Order = 22)] public System.Windows.Media.Brush PositiveDeltaBrush { get; set; } = Brushes.Lime; [Browsable(false)] public string PositiveDeltaBrushSerializable { get { return Serialize.BrushToString(PositiveDeltaBrush); } set { PositiveDeltaBrush = Serialize.StringToBrush(value); } } [XmlIgnore] [Display(Name = "Negative Delta", GroupName = "01. Profile", Order = 23)] public System.Windows.Media.Brush NegativeDeltaBrush { get; set; } = Brushes.Red; [Browsable(false)] public string NegativeDeltaBrushSerializable { get { return Serialize.BrushToString(NegativeDeltaBrush); } set { NegativeDeltaBrush = Serialize.StringToBrush(value); } } [XmlIgnore] [Display(Name = "Border", GroupName = "01. Profile", Order = 24)] public Stroke ProfileBorderStroke { get; set; } = new Stroke(Brushes.LightSeaGreen); [Browsable(false)] [Display(Name = "Font", Order = 23, GroupName = "01. Profile")] public SimpleFont ProfileLabelsFont { get; set; } = new SimpleFont() { Family = new System.Windows.Media.FontFamily("Verdana"), Size = 11 } // [Display(Name = "Show total volume & bid/ask", Order = 30, GroupName = "01. Profile")] public bool ShowTotals { get; set; } = true; #endregion
the sma file in region property the error is like this
Invalid token ‘=’ in class, struct, or interface member declaration CS1519 211 Invalid token ‘;’ in class, struct, or interface member declaration CS1519 211 Invalid token ‘=’ in class, struct, or interface member declaration CS1519 215 Invalid token ‘=’ in class, struct, or interface member declaration CS1519 220 Invalid token ‘=’ in class, struct, or interface member declaration CS1519 224 Invalid token ‘;’ in class, struct, or interface member declaration CS1519 224 Invalid token ‘=’ in class, struct, or interface member declaration CS1519 228 Method must have a return type CS1520 228 Identifier expected CS1001 228 Invalid token ‘=’ in class, struct, or interface member declaration CS1519 232 Invalid token ‘;’ in class, struct, or interface member declaration CS1519 232 Invalid token ‘=’ in class, struct, or interface member declaration CS1519 236 Method must have a return type CS1520 236 Identifier expected CS1001 236 Invalid token ‘=’ in class, struct, or interface member declaration CS1519 240 Invalid token ‘;’ in class, struct, or interface member declaration CS1519 240 Invalid token ‘=’ in class, struct, or interface member declaration CS1519 244 Method must have a return type CS1520 244 Identifier expected CS1001 244 Identifier expected CS1001 244 Type expected CS1031 244 Invalid token ‘=’ in class, struct, or interface member declaration CS1519 249 Invalid token ‘=’ in class, struct, or interface member declaration CS1519 253 Method must have a return type CS1520 253 Identifier expected CS1001 253 Type expected CS1031 253 Invalid token ‘=’ in class, struct, or interface member declaration CS1519 258 Invalid token ‘=’ in class, struct, or interface member declaration CS1519 262 Method must have a return type CS1520 262 Identifier expected CS1001 262 Type expected CS1031 262 Invalid token ‘=’ in class, struct, or interface member declaration CS1519 268 Invalid token ‘=’ in class, struct, or interface member declaration CS1519 272 Invalid token ‘;’ in class, struct, or interface member declaration CS1519 272 Invalid token ‘=’ in class, struct, or interface member declaration CS1519 277 Invalid token ‘;’ in class, struct, or interface member declaration CS1519 277 Invalid token ‘=’ in class, struct, or interface member declaration CS1519 288 Invalid token ‘;’ in class, struct, or interface member declaration CS1519 288 Invalid token ‘=’ in class, struct, or interface member declaration CS1519 299 Invalid token ‘;’ in class, struct, or interface member declaration CS1519 299 Invalid token ‘=’ in class, struct, or interface member declaration CS1519 310 Invalid token ‘;’ in class, struct, or interface member declaration CS1519 310 Invalid token ‘=’ in class, struct, or interface member declaration CS1519 321 Invalid token ‘;’ in class, struct, or interface member declaration CS1519 321 Invalid token ‘=’ in class, struct, or interface member declaration CS1519 332 Invalid token ‘;’ in class, struct, or interface member declaration CS1519 332 Invalid token ‘=’ in class, struct, or interface member declaration CS1519 343 Method must have a return type CS1520 343 Identifier expected CS1001 343 Invalid token ‘=’ in class, struct, or interface member declaration CS1519 348 Method must have a return type CS1520 348 Semicolon after method or accessor block is not valid CS1597 348 —-> in the 2 file this
Display(Name = "Mode", GroupName = "01. Profile", Order = 0)] public ProfileMode ProfileMode { get; set; } = ProfileMode.Volume; //can change this code to below one
Display(Name = "Mode", GroupName = "01. Profile", Order = 0)] public ProfileMode ProfileMode=profilemode.volume;
Invalid token ‘=’ in class, struct, or interface member declaration CS1519 26 Invalid token ‘.’ in class, struct, or interface member declaration CS1519 26 Invalid token ‘;’ in class, struct, or interface member declaration CS1519 26 Invalid token ‘=’ in class, struct, or interface member declaration CS1519 27 Invalid token ‘;’ in class, struct, or interface member declaration CS1519 27 Invalid token ‘=’ in class, struct, or interface member declaration CS1519 28 Invalid token ‘;’ in class, struct, or interface member declaration CS1519 28 Invalid token ‘=’ in class, struct, or interface member declaration CS1519 29 Invalid token ‘=’ in class, struct, or interface member declaration CS1519 30 ; expected CS1002 94 Invalid token ‘(‘ in class, struct, or interface member declaration CS1519 94 Invalid token ‘=>’ in class, struct, or interface member declaration CS1519 94 Invalid token ‘)’ in class, struct, or interface member declaration CS1519 94 ; expected CS1002 96 Invalid token ‘[‘ in class, struct, or interface member declaration CS1519 96 Identifier expected CS1001 96 Invalid expression term ‘int’ CS1525 96 Syntax error, ‘]’ expected CS1003 96 Invalid token ‘]’ in class, struct, or interface member declaration CS1519 96 Method must have a return type CS1520 96 Identifier expected CS1001 96 Invalid token ‘)’ in class, struct, or interface member declaration CS1519 96 ; expected CS1002 98 Invalid token ‘(‘ in class, struct, or interface member declaration CS1519 98 Invalid token ‘=>’ in class, struct, or interface member declaration CS1519 98 Invalid token ‘)’ in class, struct, or interface member declaration CS1519 98 ; expected CS1002 100 please helpin linq and generics amnew to programming .
revert me back asap.
Thanking you,
-
Edited by
Monday, May 8, 2017 5:21 PM
-
Edited by