error on public partial class xxx {}

B

blackdog

I compiled *.cs which contains public partial class xxx:
System.Web.UI.Page

I got errors as below:
xxx_cs.aspx.cs: error CS1518: Expected class, delegate, enum,
interface, or struck.

Please help.

Thanks
 
G

Guest

can you provide some code? its very hard to figure out a problem without all
the information....
 
B

blackdog

I compiled the following code and I got
test_cs.aspx.cs: error CS1518: Expected class, delegate, enum,
interface, or struck.

using System;
public partial class test_cs_aspx: System.Web.UI.Page
{
protected void Button1_Click(object sender, EventArgs e)
{
Label1.Text = "Hello " + TextBox1.Text;
}

}
 
T

Thomas T. Veldhouse

blackdog said:
I compiled the following code and I got
test_cs.aspx.cs: error CS1518: Expected class, delegate, enum,
interface, or struck.

using System;
public partial class test_cs_aspx: System.Web.UI.Page
{
protected void Button1_Click(object sender, EventArgs e)
{
Label1.Text = "Hello " + TextBox1.Text;
}

}

Where is the rest of the class? When you create a partial class, there must
be another part somewhere. Also, I believe this is a new keyword with .NET
2.0 (Visual Studio 2005) ... at least, I have never seen it before that.
 
M

Michael Taylor

Thomas T. Veldhouse said:
Where is the rest of the class? When you create a partial class, there
must
be another part somewhere. Also, I believe this is a new keyword with
.NET
2.0 (Visual Studio 2005) ... at least, I have never seen it before that.

There doesn't have to be another part, but there can be.

partial is new for C# in VS 2005; any chance you were building using VS 2003
or
version 7.10 of csc?
 
B

blackdog

I use Visual Studio NET 2003
Thomas said:
Where is the rest of the class? When you create a partial class, there must
be another part somewhere. Also, I believe this is a new keyword with .NET
2.0 (Visual Studio 2005) ... at least, I have never seen it before that.
 
B

blackdog

I use VS 2003, What should I do, how to change it to avoid using public
partial class.
Thanks a lot
 
J

Jon Skeet [C# MVP]

blackdog said:
I use Visual Studio NET 2003

Well that would explain why it's not working. VS.NET 2003 doesn't
compile C# 2.0.

Where did you get this partial class from in the first place? Chances
are, anything which is using partial classes could be using other
features from C#/.NET 2.0 as well.
 
B

Bjorn Abelli

blackdog said:
I use VS 2003, What should I do, how to change it to avoid
using public partial class.

Find all code for the class in question, which can be in separate source
code files, and put it into a single class definition; a single source code
file.

Then you can drop the "partial" keyword.

The "partial" keyword means just that, that the definition of the class can
be spread over separate source code files.

However, as someone already said, as the "partial" keyword appeared in 2.0,
you might stumble upon other new 2.0 things in the code as well, which
*might* make it impossible to compile in VS2003.
Thanks a lot

You're welcome.

/// Bjorn A
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top