By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
454,996 Members | 1,095 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 454,996 IT Pros & Developers. It's quick & easy.

Why this declaration is legal

P: n/a
Hi All,

I saw a code:

vertexBuffer = new VertexBuffer(
typeof(CustomVertex.TransformedColored), 3, dev, 0,
CustomVertex.TransformedColored.Format, Pool.Default);

but why not:

VertexBuffer vertexBuffer = new VertexBuffer(
typeof(CustomVertex.TransformedColored), 3, dev, 0,
CustomVertex.TransformedColored.Format, Pool.Default);

Best regards,
Boki.

Reply

May 11 '06 #1
Share this Question
Share on Google+
3 Replies


P: n/a
Boki,

They should both be legal. What is the compiler error that you are
getting with the second declaration?
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Boki" <bo******@ms21.hinet.net> wrote in message
news:11*********************@i40g2000cwc.googlegro ups.com...
Hi All,

I saw a code:

vertexBuffer = new VertexBuffer(
typeof(CustomVertex.TransformedColored), 3, dev, 0,
CustomVertex.TransformedColored.Format, Pool.Default);

but why not:

VertexBuffer vertexBuffer = new VertexBuffer(
typeof(CustomVertex.TransformedColored), 3, dev, 0,
CustomVertex.TransformedColored.Format, Pool.Default);

Best regards,
Boki.

Reply

May 11 '06 #2

P: n/a
"Boki" <bo******@ms21.hinet.net> a ecrit dans le message de news:
11*********************@i40g2000cwc.googlegroups.c om...

| I saw a code:
|
| vertexBuffer = new VertexBuffer(
| typeof(CustomVertex.TransformedColored), 3, dev, 0,
| CustomVertex.TransformedColored.Format, Pool.Default);
|
| but why not:
|
| VertexBuffer vertexBuffer = new VertexBuffer(
| typeof(CustomVertex.TransformedColored), 3, dev, 0,
| CustomVertex.TransformedColored.Format, Pool.Default);

Why not indeed ? Both are legal, the first one assumes that there is already
either a field or a local variable of type VertexBuffer called vertexBuffer.
The second line declares the variable and initialises it at the same time.

Joanna

--
Joanna Carter [TeamB]
Consultant Software Engineer
May 11 '06 #3

P: n/a

Joanna Carter [TeamB] 寫道:
"Boki" <bo******@ms21.hinet.net> a ecrit dans le message de news:
11*********************@i40g2000cwc.googlegroups.c om...

| I saw a code:
|
| vertexBuffer = new VertexBuffer(
| typeof(CustomVertex.TransformedColored), 3, dev, 0,
| CustomVertex.TransformedColored.Format, Pool.Default);
|
| but why not:
|
| VertexBuffer vertexBuffer = new VertexBuffer(
| typeof(CustomVertex.TransformedColored), 3, dev, 0,
| CustomVertex.TransformedColored.Format, Pool.Default);

Why not indeed ? Both are legal, the first one assumes that there is already
either a field or a local variable of type VertexBuffer called vertexBuffer.
The second line declares the variable and initialises it at the same time.

Joanna

--
Joanna Carter [TeamB]
Consultant Software Engineer


Hi All,
Sorry, I miss there is a public variable:

/////////////////////////////////////////////////////////////
public class Vertices : Form
{
// Our global variables for this project
Device device = null; // Our rendering device
VertexBuffer vertexBuffer = null;

Best regards,
F.Y.

May 12 '06 #4

This discussion thread is closed

Replies have been disabled for this discussion.