Details
-
Bug
-
Resolution: Done
-
Minor - P4
-
None
-
None
-
Win 7 Enterprise, VS 2013
*Location*: https://docs.mongodb.com/getting-started/csharp/client/#csharp-download-connect
*User-Agent*: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/54.0.2840.71 Safari/537.36
*Referrer*: https://docs.mongodb.com/getting-started/csharp/insert/
*Screen Resolution*: 1536 x 864
Win 7 Enterprise, VS 2013 *Location*: https://docs.mongodb.com/getting-started/csharp/client/#csharp-download-connect *User-Agent*: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/54.0.2840.71 Safari/537.36 *Referrer*: https://docs.mongodb.com/getting-started/csharp/insert/ *Screen Resolution*: 1536 x 864
-
0.25
Description
Hi, I'm supposed to use
"protected static IMongoClient _client;
protected static IMongoDatabase _database;
_client = new MongoClient();
_database = _client.GetDatabase("test");"
Upon rebuilding my code, I'm getting "Invalid expression term 'protected'. How do i resolve this?
my test code:
using System; |
using System.Collections.Generic; |
using System.Globalization; |
using System.Linq; |
using System.Text; |
using System.Threading.Tasks; |
using MongoDB.Bson; |
using MongoDB.Driver; |
|
|
namespace CSharpMongo |
{
|
class Program |
{
|
static void Main(string[] args) |
{
|
#region Insert Data with C# Driver, https://docs.mongodb.com/getting-started/csharp/insert/
|
#region Prerequisites
|
//Follow the Connect to MongoDB step to connect to a running MongoDB instance and declare and define the variable _database to access the test database. |
//Include the 3 using statements (as shown per the site mentioned above). |
#region Connect to MongoDB
|
//Add the 2 using statements in your C# program. |
//Now, connect: |
protected static IMongoClient _client; |
protected static IMongoDatabase _database; |
|
|
_client = new MongoClient(); |
_database = _client.GetDatabase("test"); |
//To specify a different host and port for the mongod instance, see the MongoClient API page |
|
|
|
|
#endregion
|
|
|
#endregion
|
#endregion
|
}
|
}
|
}
|
Thanks in advance for your help,
Tien