Error A New Expression Requires Or After Type
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site a new expression requires () or after type foreach About Us Learn more about Stack Overflow the company Business Learn more about a new expression requires () or after type c# hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join a new expression requires () or [] after type unity the Stack Overflow Community Stack Overflow is a community of 4.7 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up What does “A new expression requires (), [], or {} after type” mean? up vote 0 down vote favorite This is my code: using System; using System.Configuration; using System.Data; using System.Linq; using System.Web; using System.Web.Security; using System.Web.UI; using System.Web.UI.HtmlControls; using System.Web.UI.WebControls; using System.Web.UI.WebControls.WebParts; using System.Xml.Linq; using System.Data.SqlClient; using System.Data; public partial class _Default : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { } protected void Button1_Click(object sender, EventArgs e) { SqlConnection con = new SqlConnection(); con.ConnectionString = "Data Source=OCS-MXL930055N\\;Initial Catalog=sample;Integrated Security=True"; SqlCommand cmd = new SqlCommand con.Open("Select * from ShoppingList", con); con.Close("Select * from ShoppingList", con); } } And these are the lines I am having problems with: con.Open("Select * from ShoppingList", con)(); con.Close("Select * from ShoppingList", con)(); Any help with what they mean? I'm not too sure what I'm doing wrong. c# linq types expression requires share|improve this question edited Nov 4 '13 at 14:57 Shriroop 1,13121225 asked Nov 4 '13 at 14:30 user2952873 412 It means that the compiler needs to know somehow you're trying to initialize a new instance (or several instances) of a type. In your case add parentheses to: SqlCommand cmd = new SqlCommand(); Notice the brackets? –bump Nov 4 '13 at 14:54 add a comment| 3 Answers 3 active oldest votes up vote 5 down vote Your statement: SqlCommand cmd = new SqlCommand should be : SqlCommand cmd = new SqlCommand("Select * from ShoppingList"); Later when you are opening and closing the connection, just remove the parameters, these parameters are required for SqlCommand constructor. You may have your code like: using(SqlConnection con = new SqlConnection("Data Source=OCS-MXL930055N\\
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About Us Learn more about Stack Overflow the company Business Learn more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a http://stackoverflow.com/questions/19769933/what-does-a-new-expression-requires-or-after-type-mean community of 4.7 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up A new expression requires () or [] after type compilation error - C# up vote 5 down vote favorite The following code for a co-worker throws the following error when he tries to compile http://stackoverflow.com/questions/389644/a-new-expression-requires-or-after-type-compilation-error-c-sharp it using VS 2008: Error: A new expression requires () or [] after type Code: MyClass Structure: public class MyClass { public MyClass() {} public string Property1 { get; set; } public string Property2 { get; set; } } Sample Source Code: List
Answers Feedback Issue Tracker Blog Evangelists User Groups Navigation Home Unity Industries Showcase Learn Community Forums Answers Feedback Issue Tracker Blog Evangelists User Groups Get Unity Asset Store Unity account http://answers.unity3d.com/questions/1230544/error-cs1526-a-new-expression-requires-or-after-ty-1.html You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account Language Chinese Spanish Japanese Korean Portuguese Ask a http://www.codeproject.com/Questions/660508/A-new-expression-requires-or-after-type question Spaces Default Help Room META Moderators Topics Questions Users Badges Home / Help Room / 0 Question by importguru88 · Aug 17 at 09:20 AM · errorscripting problemspawnscript error error CS1526: A a new new expression requires () or [] after type I want to do spawnvalues . I can spawn enemy ai by z, x, . I only got one error : Here is my script : using UnityEngine; using System.Collections; public class EnemiesSpawner : MonoBehaviour { public GameObject[] enemy; public Transform [] spawnPoints; public float spawnTime = 5f; public Vector3 spawnValues; void Start () { InvokeRepeating("Spawn", spawnTime, spawnTime); //Calls a new expression the "Spawn" function every 10 seconds. } void Spawn () { int spawnPointIndex = Random.Range (0, spawnPoints.Length -1); for( int spawnCount = 2 - 1 ; spawnCount >= 0 ; --spawnCount ) Instantiate(enemy, spawnPoints[spawnPointIndex].position, spawnPoints[spawnPointIndex].rotation); Vector3 spawnPosition = new Vector3 (Random.Range (-spawnValues.x, spawnValues.x), 1, Random.Range (-spawnValues.z, -spawnValues.z); } } Comment Add comment 10 |3000 characters needed characters left characters exceeded ▼ Viewable by all users Viewable by moderators Viewable by moderators and the original poster Advanced visibility Viewable by all users 1 Reply · Add your reply Sort: 0 Best Answer Answer by saschandroid · Aug 17 at 09:45 AM Missing ")" at the end of line 18/19? Vector3 spawnPosition = new Vector3 (Random.Range (-spawnValues.x, spawnValues.x), 1, Random.Range (-spawnValues.z, -spawnValues.z); Vector3 spawnPosition = new Vector3 (Random.Range (-spawnValues.x, spawnValues.x), 1, Random.Range (-spawnValues.z, -spawnValues.z) ) ; // <= here Comment Add comment · Show 3 · Share 10 |3000 characters needed characters left characters exceeded ▼ Viewable by all users Viewable by moderators Viewable by moderators and the original poster Advanced visibility Viewable by all users importguru88 · Aug 17 at 10:06 AM 0 Share I got two errors : .cs(18,20): error CS1502: The best overloaded method match for UnityEngine.Object.Instantiate(UnityEngine.Object, UnityEngine.Vector3, UnityEngine
Tips/Tricks Top Articles Beginner Articles Technical Blogs Posting/Update Guidelines Article Help Forum Article Competition Submit an article or tip Post your Blog quick answersQ&A Ask a Question View Unanswered Questions View All Questions... C# questions Linux questions ASP.NET questions SQL questions VB.NET questions discussionsforums All Message Boards... Application Lifecycle> Running a Business Sales / Marketing Collaboration / Beta Testing Work Issues Design and Architecture ASP.NET JavaScript C / C++ / MFC> ATL / WTL / STL Managed C++/CLI C# Free Tools Objective-C and Swift Database Hardware & Devices> System Admin Hosting and Servers Java .NET Framework Android iOS Mobile SharePoint Silverlight / WPF Visual Basic Web Development Site Bugs / Suggestions Spam and Abuse Watch features Competitions News The Insider Newsletter The Daily Build Newsletter Newsletter archive Surveys Product Showcase Research Library CodeProject Stuff communitylounge Who's Who Most Valuable Professionals The Lounge The Insider News The Weird & The Wonderful The Soapbox Press Releases Non-English Language > General Indian Topics General Chinese Topics help What is 'CodeProject'? General FAQ Ask a Question Bugs and Suggestions Article Help Forum Site Map Advertise with us About our Advertising Employment Opportunities About Us Ask a Question All Questions All Unanswered FAQ A new expression requires (), [], or {} after type Rate this: Please Sign up or sign in to vote. See more: C# WPF Hi I start learning Task and asynchronous programming in C# WPF, and wrote following line of code Task Posted 28-Sep-13 18:28pm chandan0285468 Updated 28-Sep-13 18:38pm v2 Add a Solution Comments Sergey Alexandrovich Kryukov 29-Sep-13 1:38am It's a good idea to learn the syntax of the language before writing some code, especially on such and adva