Click here to Skip to main content
15,900,511 members
Everything / Syntax

Syntax

syntax

Great Reads

by Britto selva pandian J
Things to remember while using Rest API calls on SharePoint hosted App for Office 365/SharePoint Online
by Pete O'Hanlon
How to use arrays to manage multiple items
by Pete O'Hanlon
What is an array and how to use it to manage multiple items
by ASP.NET Community
IntroductionLINQ is one of the new entrants in C# 3.0, introduced as part of .NET 3.5. As you are already aware, LINQ is a unified querying

Latest Articles

by Pete O'Hanlon
How to use arrays to manage multiple items
by Christian Specht
Overlay gallery images with logo using one of Hugo's available image filters
by Jon Randy
Safe monkey-patching for JavaScript
by Pete O'Hanlon
What is an array and how to use it to manage multiple items

All Articles

Sort by Updated

Syntax 

24 Jul 2023 by Sonhospa
Hi all, I'm trying to get several Task(Of IEnumerable(Of String)) – as the result of another LINQ query which is well populated – and try to get the String-Enumerables all into one single set of IEnumerable(Of String) using LINQ. I guess it's...
24 Jul 2023 by Richard Deeming
Dave is correct; if you add in the variable types, you can see the problem more easily: Dim entriesTasksQuery As IEnumerable(Of Task(Of IEnumerable(Of String))) = ... It's obvious that you can't pass the entriesTasksQuery variable to a...
24 Jul 2023 by Dave Kreskowiak
You're trying to cast the Task objects into strings. You, obviously, can't do that. You need the Result property of each Task, then you can concatenate those together.
14 May 2023 by Richard MacCutchan
Again, you have already posted this question at What does this mean in Prolog? - Artificial Intelligence Discussion Boards[^]. Please post your questions in one place only.
25 Feb 2023 by Pete O'Hanlon
How to use arrays to manage multiple items
12 Dec 2022 by Safa Hassan
let start = alert( "This is a shape detector program.\nYou will be asked to enter four sides and four angles to determine the quadrilateral." ); let obj = {}; for (let s = 1; s
15 Sep 2022 by Christian Specht
Overlay gallery images with logo using one of Hugo's available image filters
26 Aug 2022 by Jyde24
Can someone help me out here, I just started learning and I am already having headaches.... CREATE TABLE Delat( Staff_id INT PRIMARY KEY, First_Name VARCHAR(20), Last_Name VARCHAR(20), Department VARCHAR(30), Designation...
26 Aug 2022 by Matas - developer
QUERY FAILED .You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'WHERE darb_id = 30, darb_title = 'Pavadinimas', darb_date = now(), darb_user' at line 1 My...
26 Jul 2022 by Richard MacCutchan
You have got your indentations wrong, so the elif statements are not being recognised as connected to the previous if. It should be: elif o == "7": price=float(input("What was the original price of your purchase:")) if price
26 Jul 2022 by muzeD12
I am making a calculator. I have elif statements with if statements inside. I think that is causing the error but it just made more errors. elif o == "7": price=float(input("What was the original price of your purchase:")) if price
18 Jul 2022 by Jon Randy
Safe monkey-patching for JavaScript
13 May 2022 by Member 14463408
Please help me fix this error message I have received. It says the error is with line 9. Here's the code.
17 Feb 2022 by Pete O'Hanlon
What is an array and how to use it to manage multiple items
1 Feb 2022 by Patrick Skelton
In C#, I thought the rule was that any collection with an Add() function could participate in declarative initialisation? I have two such collections that are nested one inside the other. Is there a way to declaratively initialise it, rather than...
31 Jan 2022 by Patrick Skelton
This is perhaps as close as I am going to get: private static Dictionary _dataStructure = new Dictionary { [ "One" ] = new MyDataPlot { { 2, 6 }, { 7, 4 } }, [ "Two" ] = new MyDataPlot { { 5, 16...
31 Jan 2022 by Richard Deeming
A collection initializer can work with multiple parameters - for example: private static Dictionary _dataStructure = new() { ["Foo"] = new MyDataPlot { { 0, 1 }, { 2, 3 }, { 4, 5 }, }, }; ...
31 Jan 2022 by OriginalGriff
Because Add is a void method, you can't use it directly in an initializer. Change it to return the MyDataPlot instance, and it works: public class MyDataPoint { public MyDataPoint(int x, int y) { X = x; Y = y; } public...
20 Jan 2022 by M Imran Ansari
Try the following link: Python program to print the binary value of the numbers from 1 to N - GeeksforGeeks[^]
20 Jan 2022 by shri harshan
input: 2 2 5 output: 1 10 1 10 11 100 101 we should get three inputs. What I have tried: a = int(input()) b = int(input()) c = int(input())
19 Jan 2022 by shri harshan
example: e = ['6']['12'] i want to get ['6','12'] What I have tried: ive tried join and extend functions but it didt'nt work or I don't know if I made a mistake.
19 Jan 2022 by CPallini
Quote: e = ['6']['12'] That's not valid Python syntax. Quote: yes i got a output like that the whole program is a = int(input()) b = int(input()) c = int(input()) for i in range(a, b+1): if i%c==0: d = str(i) e = d.split() print(e,end=" ") So it...
25 Oct 2021 by Pete O'Hanlon
Getting started with TypeScript
22 Aug 2021 by Matt Scarpino
This article explains how to analyze Python code using the open-source ast package
28 May 2021 by Jarod L
I am getting a syntax error from this dictionary, can someone help me find where the issue is? Here's the dictionary: grade_gpas =...
28 May 2021 by Patrice T
Quote: Checking the commas, the parenthesis, etc. You need to check better. grade_gpas = { "A+":tuple(range(97,100)),"A":tuple(range(93,96)),"A-":tuple(range(90,92)), "B+":tuple(range(87,89)),"B":tuple(range(83,86)),"B-":tuple(range(80,82)),...
28 May 2021 by Richard MacCutchan
grade_gpas =...
18 Feb 2021 by Elham Alaei
These are my code and i noticed an error like this : File "", line 6 B_ ivtt1 = Beta('B_ ivtt1', 0, None, None, 0) ^ SyntaxError: invalid syntax my code: ASC_autod = Beta('ASC_autod', 0, None, None,...
18 Feb 2021 by OriginalGriff
Look at the line it complains about - it tells you exactly which line it is (line 6) and even takes the time to highlight where the problem is: B_ ivtt1 = Beta('B_ ivtt1', 0, None, None, 0) ^ What is the space doing there between "B_"...
9 Feb 2021 by Member 15068870
I'm kinda new to php, i was doing function and this syntax error happened function invalidUid($username) { $result; if (!preg_match("/^[a-zA-Z0-9]*$/"), $username) { #that is line 15 $result = true; } else { $result = false; } return...
9 Feb 2021 by 20212a
You just need to match up your parentheses: if (!preg_match("/^[a-zA-Z0-9]*$/", $username)) preg_match takes 2 (or more) parameters.
10 Jan 2021 by Peter Belcak
A short review of the literature on the subject of multi-machine parsing
6 Jan 2021 by Richard MacCutchan
See ffmpeg Documentation[^]
18 Dec 2020 by Member 15025216
This code is for an online emulator, and the syntax is driving me up a wall. No matter how I try to rearrange it, I always get errors with something or another. m_ResHue = 0; m_ResAmount = 0; m_System =...
18 Dec 2020 by OriginalGriff
We really can't help you with that limited a fragment and no error message: if I copy'n'paste that code into a new method, I get 141 errors, starting with CS1519 Invalid token 'else' in class, struct, or interface member declaration because the...
4 Dec 2020 by Demetri K.2
This error keeps popping up in one of the classes I use. The error is not tied to any other part of the code it just keeps activating on the first line of code in the Application class. " public static string $ROOT_DIR; " is the problem right...
4 Dec 2020 by Chris Copeland
My understanding from reading the documentation[^] on this is that static properties don't support the type being explicitly declared. I couldn't find any examples of it, so perhaps just remove the string type declaration?
12 Sep 2020 by cobusbo
Hi I got a syntax problem and have been looking at the lines for bout an hour now and cant find my froblem can anybody help please?echo "" . "(" . date( 'D H:i:s', $list['StringyChat_time'] ) . ") " . "" . "" . $list['StringyChat_name'] . "" . " : " ....
23 Jul 2020 by Pino Carafa
I'm trying to deal with a problem with "invalid high surrogate characters" in a string. One of the examples I found online shows how to create such a string in C# string s = "a\ud800b"; The person who created the example then claims that ...
23 Jul 2020 by Patrice T
Quote: How do I translate this very simple C# syntax to VB? Not exactly a solution, but in the news : https://ai.facebook.com/blog/deep-learning-to-translate-between-programming-languages[^] Automatic translation is still a subject of research....
23 Jul 2020 by Pino Carafa
OriginalGriff's solution is the perfect solution to this question. I'm just posting another "answer" here as it allows me to format the code I'm about to post. My original intent was to DEAL with such strings, basically finding a way to remove...
23 Jul 2020 by OriginalGriff
Dim s As String = "a" + ChrW(&HD800) + "b" Dim t As String = s.Normalize() The reason it fails is that "D800" is not a valid Unicode characters, they are "surrogates" and can;t be "normalized": FAQ - UTF-8, UTF-16, UTF-32 & BOM[^]
18 Jul 2020 by Patrice T
Quote: I have a syntax error in my index.php in lines 35 and 49. How can I fix it? My website shows the following error message " ERROR WHOOPS! WE'VE GOT A PROBLEM syntax error, unexpected end of file The page you were looking for doesn't exist....
18 Jul 2020 by Member 14209003
I have a syntax error in my index.php in lines 35 and 49. How can I fix it? My website shows the following error message " ERROR WHOOPS! WE'VE GOT A PROBLEM syntax error, unexpected end of file The page you were looking for doesn't exist. Sorry...
18 Jul 2020 by OriginalGriff
Look at the code, paying attention to the end of the file: template.'/blocks/config.php'); ?>
17 Jul 2020 by Member 14209003
. * * For any bug, error please contact us * We...
17 Jul 2020 by Member 14209003
. * * For any bug, error please contact us * We...
23 Jun 2020 by Patrice T
SQL = "INSERT INTO Employee (Email, First_name, Last_name, Phone, Admin, Active)" SQL += "VALUES ('" + email + "','" + first_name + "','" + last_name + "','" + phone + "','" + admin + "','" + active + "');" Not necessary a solution to your...
23 Jun 2020 by Member 14870365
HTML Employee Add Employee Table Email:
23 Jun 2020 by MadMyche
As Patrice and 0x01AA have pointed out, you should watch for spaces and other separators. Your statement does not have a space between the parentheses VALUES, and then an empty value at the end of the statement INSERT... , Active)VALUES(... '" +...
22 Jun 2020 by Maciej Los
Not an answer, but suggestion. I'd suggest to use PyPika · PyPI[^]. Why? Quote: The motivation behind PyPika is to provide a simple interface for building SQL queries without limiting the flexibility of handwritten SQL. Designed with data...
22 Jun 2020 by Member 14870365
#! /usr/bin/env python3 print('Content-type: text/html\n') import MySQLdb, cgi def results_table(records): html = """
22 Jun 2020 by Patrice T
Quote: Can't find syntax error anywhere in code Syntax error is in SQL command I would start with: SQL = "INSERT INTO Employee (Email, First_name, Last_name, Phone, Admin, Active)" ' ...
24 Apr 2020 by Patrice T
Very nice way to build a SQL query subject to injection. $query = "UPDATE darb SET "; $query .= "WHERE darb_id = {$the_darb_id}, "; $query .="darb_title = '{$darb_title}', "; $query .="darb_date = now(), "; $query .="darb_user =...
24 Apr 2020 by The Cool Cat
It looks like you put the 'WHERE' clause in the beginning of the query where it should be placed at the end of the query. $query = "UPDATE darb SET "; $query .="darb_title = '{$darb_title}', "; $query .="darb_date = now(), "; $query...
24 Apr 2020 by MadMyche
2 problems with your script. The big problem is that you stumbled on a 20 year vulnerability called SQL Injection; perhaps you have heard of it. NEVER EVER should you create an SQL command by combining commands and user entered text. What you...
24 Apr 2020 by Garth J Lancaster
1) Your SQL WHERE Clause syntax is 'quite interesting' - the use of commas ',' to separate the terms for instance What would happen if you tried replacing the commas with 'AND', so you would end up with ... WHERE darb_id = 30 AND ...
7 Oct 2019 by OriginalGriff
One way to do it is to give the GenerateKey class a static constructor: Static Constructors - C# Programming Guide | Microsoft Docs[^] The static constructor will be automatically called before any instance of the class is created, so if your plugin creates a GenerateKey instance as part of...
7 Oct 2019 by Member 14605491
Hi, im currently working on the license control for my c# plugin. I already created a class called GenerateKey(Wins Form) and planning to load this class before the user gets to install the plugin (Main Program). I found a syntax below. My questions are im not sure which event supposed to be...
1 Oct 2019 by #realJSOP
You can just return String.Empty without doing the await. Of course, that would make the method synchronous (because there's no await statement), but I don't see that as a bad thing if it's merely a default implementation.
1 Oct 2019 by Patrick Skelton
In a base class, I am trying to create a default implementation for a function returning Task. I can work out how to do this 'long-hand' but I can't help thinking there is a neater way of writing this. This is my current version: protected virtual async Task MyFunction()...
1 Oct 2019 by Richard Deeming
Simple - just remove the async keyword: protected virtual Task MyFunction() { return Task.FromResult(string.Empty); } If your task completes synchronously most of the time, you might want to consider using ValueTask instead. Understanding the Whys, Whats, and Whens of ValueTask |...
26 Sep 2019 by Member 14605133
Hi, I have an error in my code, I am learning php 5.6 language, but this error can't find a solution Parse error: syntax error, unexpected '$password' (T_VARIABLE), expecting identifier (T_STRING) in C:\wamp64\www\cms\include\registor.php on line 63 this line 63 -> $password =...
1 Aug 2019 by Member 14547089
I am trying to calculate shipping performance- Im getting stuck in several areas and I hope i can get some help! I have an Estimated Ship Date, an Appt Date, and an Actual Ship date. Im measuring warehouse performance, so in most cases shipments leave same day. But in others, they may leave a...
1 Aug 2019 by MadMyche
Richard's answer is correct; and for ad-hoc queries or in a report this would be the way to go The first thing you need to understand is that DateTime items are actually numbers, and that any math you are doing with them is a conversion to the number, perform the math on the number, and convert...
1 Aug 2019 by Richard Deeming
Simple: calculate the total difference in minutes, and use division and the modulus operator[^] to convert that to days, hours, and minutes. SELECT EstimatedShipDate, AppointmentShipDate, ActualShipDate, DateDiff(minute, IsNull(AppointmentShipDate, EstimatedShipDate),...
12 Jul 2019 by Patrick Skelton
This is a follow-on to another question I asked here: https://www.codeproject.com/Answers/5162098/How-do-I-convert-this-LINQ-query-to-function-synta#answer1 I am generating the XML I require using the following code: bool includeDetails = true; XElement breakdown = new XElement ( "Breakdown",...
12 Jul 2019 by Richard Deeming
As discussed in the comments, the code you've shown is correct, and the bug has now disappeared. Demo: Optional Xml | C# Online Compiler | .NET Fiddle[^]
12 Jul 2019 by Patrick Skelton
This piece of LINQ-to-XML that I found (LINQ To XML Tutorials with Examples | DotNetCurry[^]) appears to do exactly what I want. For consistency with the rest of the code I am working on, I'd like to express it using the LINQ lamda functions, not the keywords (i.e. .From() instead of from). I...
11 Jul 2019 by Maciej Los
I have no idea what you mean by "standard C# LINQ functions"... If you would like to use Non-linq solution, you can loop through the collection of customers by using for or foreach statement: List nodes = new List(); foreach(Customer c in customers) { var node = new...
6 Jun 2019 by cassert24
For those who are searching for a quick template code for the C++ replacement of C# properties, this is it.
24 May 2019 by jsc42
You have 4 'else if' statements but there is no initial 'if' statement. Your code should look something like ...
24 May 2019 by User 11060979
You start with an else if else if($contact == "entered_email_adress@yourdomain.com") I think it should be more only an if if($contact == "entered_email_adress@yourdomain.com") Note: I'm not experienced in php... [Edit] Think also about if no condition matches. In this case you should not...
24 May 2019 by phil.o
You can try to replace each else if with elseif. This statement has no space between words in PHP.
21 Aug 2018 by Keviniano Gayo
To get a specific type e.g. Fruit, you can do this: IEnumerable AllFruits1 = Enumeration.GetAll(); If you have another extended enum type like CardType: public abstract class CardType : Enumeration ... IEnumerable AllCardType1 = Enumeration.GetAll();...
21 Aug 2018 by Patrick Skelton
I decided one of the enums in my project might benefit from being more intelligent and followed the Microsoft example on the following page: Microsoft Extended Enum This is a cut-down version of my code: public abstract class Enumeration : IComparable { protected Enumeration() {} ...
21 Aug 2018 by willifritz
Fruit must have a parameterless constructor. Add public Fruit() { } to your Fruit class and var AllFruits2 = Fruit.GetAll(); should work.
30 Apr 2018 by Member 13805752
this is my code: CREATE TABLE Customers ( CustomerID varchar(25) NULL, LastName varchar(20) NULL, FirstName varchar(35) NULL, EmailAddress varchar(35) NULL, Address varchar(35) NULL, City varchar(25) NULL, State varchar(15) NULL, ZIP varchar(5) NULL, Country varchar(20) NULL, ...
30 Apr 2018 by Patrice T
You should try without space in fields names: ... HomePhone varchar(15) NULL, MobilePhone varchar (15) NULL, ... INSERT INTO Customers (CustomerID, LastName, FirstName, EmailAddress, Address, City, State, ZIP, Country, HomePhone, MobilePhone, Fax, Coupon Customer) VALUES ('1', 'Wacker',...
3 Apr 2018 by Member 13751131
I'm using a Mac osx. I know that this code in the terminal will replace all txt files that include "hello" with "hiThere" in the folder named "world": perl -pi -w -e 's/hello/hiThere/g;' ~/Desktop/world/*.txt But inside that world folder there are other folders which have other txt files...
1 Mar 2018 by Richard MacCutchan
See 7.2. codecs — Codec registry and base classes — Python 3.6.4 documentation[^].
1 Mar 2018 by TUD111
I am trying to open a csv file in python 3 and when ever I do it says (Unicode error)'unicodeescape' codec can't decode bytes in position 2-3: truncated /UXXXXXXXX escape It highlights the ( after open/ before 'C:\Users\Me\Desktop\csv file.csv' I'm not sure what the error is since I don't know...
19 Oct 2017 by Member 13474080
I am getting this error: inline assembler syntax error in 'opcode'; found '(' I don't know where I have gone wrong. What I have tried: The code is: for (i = 0; items[i] != 0; i++) { for (j = 0; j
19 Oct 2017 by Rick York
Lose the second for loop with the variable j. There is no need for that. Also, there is no need for this to be inline assembler. That is all C code.
19 Oct 2017 by OriginalGriff
Take the lines which switch you into and output assembler out of your C code: __asm Looking at your previous question: How do I print a certain number of stars in C programming?[^] I'd say you don't need any assembler - you only ever need it for very specific things you can't do in C - and a...
1 Sep 2017 by Britto selva pandian J
Things to remember while using Rest API calls on SharePoint hosted App for Office 365/SharePoint Online
22 Aug 2017 by Ivan Yakimov
Do you know, that keyword 'new' can be used in a definition of class members? I knew about it, but have never used it for many years I work in the software industry. But recently, I have found a couple of scenarios where this opportunity is very useful. Here, I want to share my findings.
8 May 2017 by Member 13188016
Im new to programming, there is some part that made me confuse when learning pointer. int main() { char string[]="hello"; char *my_pointer=string; printf("first character is %c", *my_pointer); return 0; } output : first character is h code 2: int main() { char...
8 May 2017 by Richard MacCutchan
Case 1: printf("first character is %c", *my_pointer); You are telling printf to output a single character (%c) so the parameter after the format string must be a single character. Since the character is inside an array pointed to by my_pointer it needs to be extracted from the array, and the...
8 May 2017 by CPallini
Because they are really different beasts. I would suggest you reading a tutorial on the topic, like, for instance: Everything you need to know about pointers in C[^].
8 May 2017 by Rick York
Another way to look at the asterisk is as the pointer dereference operator. It obtains the value of where pointer is aimed which for an array is the first item of the array. In printf, %s refers to a string, an array of characters so the address of the array needs to be passed. The %c format...
13 Apr 2017 by Muhammd Aamir
HI everyone i am new to mvc i am facing a problem, i have a simple view that contains a form and a foreach loop the syntax of the loop goes fine if i did this @model IEnumerable but the syntax of labelfor give me error and if i did this @model...
13 Apr 2017 by Karthik_Mahalingam
Quote: but how i can use both in my view. it shall be done in this way if you need to show from only one model @Html.LabelFor(model => model.First().Name, "Name", htmlAttributes: new { @class = "control-label col-md-2" })
13 Apr 2017 by NightWizzard
The declaration @model IEnumerable tells the view, that the provided data is a kind of collection of type Students - this can be used in a loop. The declaration @model SearchBox.Models.Students tells the view that there is only a single object of type students...
12 Apr 2017 by Patrick Skelton
I think this question might be stupidly simple, but I'm new to lambdas and just can't work out the syntax for the following (or if it is even possible). Is is possible to rewrite the following code fragment using an inline lambda in the Thickness constructor? double visualUnits = 0.0;...
12 Apr 2017 by Patrick Skelton
It seems, as has been commented, I was over complicating this. It doesn't require a lambda at all. The following 'standard' C# syntax works fine: Padding = new Thickness( 10.0, ( Device.RuntimePlatform == Device.iOS ) ? 20.0 : 0.0, 10.0, 5.0 ); I knew the question was probably stupidly...
12 Apr 2017 by Richard MacCutchan
Quote: they won't even compile. Then that should give you a clue. I don't think there is anything to be gained from over complicating a constructor. See lambda expressions - Google Search[^].
20 Dec 2016 by Member 9983063
when i am insert data so i am getting an error like thisAdditional information: Syntax error (missing operator) in query expression '@Phone No'.What I have tried:for (int i = 0; i
20 Dec 2016 by Patrice T
Try to replace:VALUES(@Column1, @Column2, @Column3, @Date, @ReceiptNo, @DeliveryPerson, @Report, @Flavours, @Name , @Phone No)withVALUES(@Column1, @Column2, @Column3, @Date, @ReceiptNo, @DeliveryPerson, @Report, @Flavours, @Name , \"@Phone No\")
20 Dec 2016 by Dave Kreskowiak
You cannot put a space in a variable name. You have: @Report, @Flavors, @Name , @Phone No)";.. and. command.Parameters.AddWithValue("@Phone No", row.Cells[6].Value);Remove the space from "Phone No".