Search Results

Search found 2229 results on 90 pages for 'newbie'.

Page 22/90 | < Previous Page | 18 19 20 21 22 23 24 25 26 27 28 29  | Next Page >

  • Convert the code into lambda/LINQ(C#3.0)

    - by Newbie
    How to convert the below code into lambda if (ds != null && ds.Tables.Count > 0) { dtAsset = ds.Tables["AssetData"]; dtCharecteristics = ds.Tables["CharacteristicsData"]; for (int i = 0; i < dtAsset.Rows.Count; i++) { for (int j = 0; j < dtCharecteristics.Rows.Count; j++) { if (dtAsset.Rows[i]["AssetId"].Equals(dtCharecteristics.Rows[j]["AssetId"])) { objAttributesCollection.Add(new Attributes { AttributeCode = Convert.ToString(dtCharecteristics.Rows[j]["AttributeCode"]), TimeSeriesData = fn(Convert.ToDateTime(dtCharecteristics.Rows[j]["StartDate"]), Convert.ToString(dtCharecteristics.Rows[j]["Value"])) }); } } objAssetCollection.Add(new Asset { AssetId = Convert.ToInt32(dtAsset.Rows[i]["AssetId"]), AssetType = Convert.ToString(dtAsset.Rows[i]["AssetCode"]), AttributeCollection = objAttributesCollection }); objAttributesCollection = new List<Attributes>(); } } I am using C#3.0 There is nothing wrong in the code but for the sake of learning I want to do this. Thanks

    Read the article

  • regex problem with url

    - by newBie
    i need to find regex that suitable with this.. [url]%252FShowOneUserReview-g298570-d301416-r63722677%26sl%3Dzh%26tl%3Den_US%26hl%3Den_US%26ie%3DUTF-8 its situated in is it possible for me to find only [url]...-8?

    Read the article

  • problem with sql statement using vb.net

    - by newBie
    hi i got some problem i got this 3 line statement: Dim infoID As Integer = objCommand1.ExecuteScalar() Dim strSQL2 As String = "insert into feedBackHotel (infoID, feedBackView) values(" + infoID + ",'" + FeedBack + "')" Dim objCommand2 As New SqlCommand(strSQL2, conn) objCommand2.ExecuteNonQuery() the problem here is..the strSQL2 can capture the infoID from previous statement, but it didnt insert into the database. it will pop out this error "Conversion from string "insert into feedBackHotel (infoI" to type 'Double' is not valid." in both table related, use same data type (int) but for the feedBackHotel's infoID i allow it to be null..bcoz if i make it not null, it will show another error.. im using vb.net ..can anyone help?

    Read the article

  • Cannot understand the behaviour of dotnet compiler while instantiating a class thru interface(C#)

    - by Newbie
    I have a class that impelemnts an interface. The interface is public interface IRiskFactory { void StartService(); void StopService(); } The class that implements the interface is public class RiskFactoryService : IRiskFactory { } Now I have a console application and one window service. From the console application if I write the following code static void Main(string[] args) { IRiskFactory objIRiskFactory = new RiskFactoryService(); objIRiskFactory.StartService(); Console.ReadLine(); objIRiskFactory.StopService(); } It is working fine. However, when I mwrite the same piece of code in Window service public partial class RiskFactoryService : ServiceBase { IRiskFactory objIRiskFactory = null; public RiskFactoryService() { InitializeComponent(); objIRiskFactory = new RiskFactoryService(); <- ERROR } /// <summary> /// Starts the service /// </summary> /// <param name="args"></param> protected override void OnStart(string[] args) { objIRiskFactory.StartService(); } /// <summary> /// Stops the service /// </summary> protected override void OnStop() { objIRiskFactory.StopService(); } } It throws error: Cannot implicitly convert type 'RiskFactoryService' to 'IRiskFactory'. An explicit conversion exists (are you missing a cast?) When I type casted to the interface type, it started working objIRiskFactory = (IRiskFactory)new RiskFactoryService(); My question is why so? Thanks.(C#)

    Read the article

  • how to maintain session in cURL in php?

    - by newbie programmer
    how can we maintain session in cURL? i'am having a code the sends login details of a site and logs in successfully i need to get the session maintained at the site to continue. here is my code that used to login to the site using cURL <?php $socket = curl_init(); curl_setopt($socket, CURLOPT_URL, "http://www.XXXXXXX.com"); curl_setopt($socket, CURLOPT_REFERER, "http://www.XXXXXXX.com"); curl_setopt($socket, CURLOPT_POST, true); curl_setopt($socket, CURLOPT_USERAGENT, $agent); curl_setopt($socket, CURLOPT_POSTFIELDS, "form_logusername=XXXXX&form_logpassword=XXXXX"); curl_setopt($socket, CURLOPT_COOKIESESSION, true); curl_setopt($socket, CURLOPT_COOKIEJAR, "cookies.txt"); curl_setopt($socket, CURLOPT_COOKIEFILE, "cookies.txt"); $data = curl_exec($socket); curl_close($socket); ?>

    Read the article

  • Problem in converting ToDictionary<Datetime,double>() usinh LINQ(C#3.0)

    - by Newbie
    I have written the below return (from p in returnObject.Portfolios.ToList() from childData in p.ChildData.ToList() from retuns in p.Returns.ToList() select new Dictionary<DateTime, double> () {p.EndDate, retuns.Value }).ToDictionary<DateTime,double>(); Getting error No overload for method 'Add' takes '1' arguments Where I am making the mistake I am using C#3.0 Thanks

    Read the article

  • how to download page from source code

    - by newBie
    i need to download page from source code..for example Cellini's Italian Restaurant i want to download the "/len/aaproximat...php"..i didnt find the suitable regex for it..and i need to download that page..can anyone help? im using vb.net

    Read the article

  • Getting certain rows from list of rows(C#3.0)

    - by Newbie
    I have a datatable having 44 rows. I have converted that to list and want to take the rows from 4th row till the last(i.e. 44th). I have the below program IEnumerable<DataRow> lstDr = dt.AsEnumerable().Skip(4).Take(dt.Rows.Count); But the output is Enumeration yielded no results I am using c#3.0 Please help.

    Read the article

  • How to debug properly and find causes for crashes?

    - by Newbie
    I dont know what to do anymore... its hopeless. I'm getting tired of guessing whats causing the crashes. Recently i noticed some opengl calls crashes programs randomly on some gfx cards. so i am getting really paranoid what can cause crashes now. The bad thing on this crash is that it crashes only after a long time of using the program, so i can only guess what is the problem. I cant remember what changes i made to the program that may cause the crashes, its been so long time. But luckily the previous version doesnt crash, so i could just copypaste some code and waste 10 hours to see at which point it starts crashing... i dont think i want to do that yet. The program crashes after i make it to process the same files about 5 times in a row, each time it uses about 200 megabytes of memory in the process. It crashes at random times while and after the reading process. I have createn a "safe" free() function, it checks the pointer if its not NULL, and then frees the memory, and then sets the pointer to NULL. Isn't this how it should be done? I watched the task manager memory usage, and just before it crashed it started to eat 2 times more memory than usual. Also the program loading became exponentially slower every time i loaded the files; first few loads didnt seem much slower from each other, but then it started rapidly doubling the load speeds. What should this tell me about the crash? Also, do i have to manually free the c++ vectors by using clear() ? Or are they freed after usage automatically, for example if i allocate vector inside a function, will it be freed every time the function has ended ? I am not storing pointers in the vector. -- Shortly: i want to learn to catch the damn bugs as fast as possible, how do i do that? Using Visual Studio 2008.

    Read the article

  • How to rewrite the following?(C#3.0)

    - by Newbie
    I am trying to write the following double sum_res = 0.0; double yhat = 0; double res = 0; int n = 0; for(int i=0;i<x.Count;i++) { yhat = inter + (slp*x[i]); res = yhat - y[i]; n++; } using lambda but somehow not able to get it work(compile time error) Enumerable.Range(0, x.Count).Select(i => { yhat = inter + (slp * x[i]); res = yhat - y[i]; sum_res += res * res; n++; }); Error: The type arguments for method 'System.Linq.Enumerable.Select(System.Collections.Generic.IEnumerable, System.Func)' cannot be inferred from the usage. Try specifying the type arguments explicitly. Help needed. Thanks

    Read the article

  • Can this extension method be improve

    - by Newbie
    I have the following extension method public static class ListExtensions { public static IEnumerable<T> Search<T>(this ICollection<T> collection, string stringToSearch) { foreach (T t in collection) { Type k = t.GetType(); PropertyInfo pi = k.GetProperty("Name"); if (pi.GetValue(t, null).Equals(stringToSearch)) { yield return t; } } } } What it does is by using reflection, it finds the name property and then filteres the record from the collection based on the matching string. This method is being called as List<FactorClass> listFC = new List<FactorClass>(); listFC.Add(new FactorClass { Name = "BKP", FactorValue="Book to price",IsGlobal =false }); listFC.Add(new FactorClass { Name = "YLD", FactorValue = "Dividend yield", IsGlobal = false }); listFC.Add(new FactorClass { Name = "EPM", FactorValue = "emp", IsGlobal = false }); listFC.Add(new FactorClass { Name = "SE", FactorValue = "something else", IsGlobal = false }); List<FactorClass> listFC1 = listFC.Search("BKP").ToList(); It is working fine. But a closer look into the extension method will reveal that Type k = t.GetType(); PropertyInfo pi = k.GetProperty("Name"); is actually inside a foreach loop which is actually not needed. I think we can take it outside the loop. But how? PLease help. (C#3.0)

    Read the article

  • PotgreSQL 2D array to rows

    - by PostGreSQL newbie
    Hello, I am new to PostgreSQL array's. I am trying to a write a procedure to convert array-into-rows, and wanted following output: alphabet | number ---------+---------- A | 10 B | 10 C | 6 D | 9 E | 3 from following: id | alphabet_series -------+-------------------------------------------------------------------------------------------------- 1 | {{A,10},{B,10},{C,6},{D,9},{E,3},{F,9},{I,10},{J,17},{K,16},{L,17},{M,20},{N,13},{O,19}} I have searched for array-to-rows functions, but they all seems to accept 1-d array. but in this case, it is 2-d array. Any pointers will be appreciated. Many thanks.

    Read the article

  • Problem in appending a string to a already filled string builder(at the beginning by using INSERT) a

    - by Newbie
    I have a string builder like StringBuilder sb = new StringBuilder("Value1"); sb.AppendLine("Value2"); Now I have a string say string str = "value 0"; I did sb.Insert(0,str); and then string[] strArr = sb.ToString().Trim().Replace("\r", string.Empty).Split('\n'); The result I am getting as (Array size of 2 where I should get 3) [0] value 0 Value1 [1] value2 But the desired output being [0] Value 0 [1] Value1 [2] Value2 Where I am going wrong? I am using C#3.0 Please help.. It 's urgent Thanks

    Read the article

  • How do I show all group headers in Access 2007 reports?

    - by Newbie
    This is a question about Reports in Access 2007. I'm unsure whether the solution will involve any programming, but hopefully someone will be able to help me. I have a report which lists all records from a particular table (call it A), and groups them by their associated record in a related table (call it B). I use the 'group headers' to add the information from table-B into the report. The problem occurs when I filter the records from table-A that are shown in the report. If I filter out all table-A records that relate to a particular record (call it X) in table-B, the report no longer shows the record-X group header. As a possible workaround, I have tried to ensure that I have one empty record in table-A for each of the records in table-B. That way I can specify NOT to filter out these empty records. However, the outcome is ugly one-record-high blank spaces at the start of each group in the report. Does anyone know of an alternative solution?

    Read the article

  • Commonly use Utility methods in projects

    - by Newbie
    In many projects, we come across various utility methods, e.g. Email validation Convert from dd/mm/yyyy to mm/dd/yyyy or other date formats I would like to know as what are the varoius common utility method that we genrally use? I know that some methods are project specific but many will be common. I searched in net to get a list of as much as possible but none I found to be very informative. Could you please help? Well I am more interested in the method behaviour and not in their implementation. If I can get the method names and what it does e.g. ConvertMMDDYYYY to ConvertDDMMYYYY it will server my purpose. Thanks

    Read the article

  • How to specify comma , space unicode value in app.config(C#3.0)

    - by Newbie
    In the app.config file if I use <add key = "FileDelimeter" value ="&#2c;"/> as unicode for COMMA, it is throwing error Invalid character in a decimal number 'c' For SPACE, <add key = "FileDelimeter" value ="&#20;"/> the error is Character'', hex value 0*14 is illegal in xml while <add key = "FileDelimeter" value ="&#09;"/> for "\t" worked. Where is the mistake? Kindly give a generic solution. Thanks

    Read the article

  • Is there any alternative way of writing this switch statement(C#3.0)

    - by Newbie
    Can it be done in a better way public static EnumFactorType GetFactorEnum(string str) { Standardization e = new Standardization(); switch (str.ToLower()) { case "beta": e.FactorType = EnumFactorType.BETA; break; case "bkp": e.FactorType = EnumFactorType.BOOK_TO_PRICE; break; case "yld": e.FactorType = EnumFactorType.DIVIDEND_YIELD; break; case "growth": e.FactorType = EnumFactorType.GROWTH; break; case "mean": e.FactorType = EnumFactorType.MARKET_CAP; break; case "momentum": e.FactorType = EnumFactorType.MOMENTUM; break; case "size": e.FactorType = EnumFactorType.SIZE; break; case "stat_fact1": e.FactorType = EnumFactorType.STAT_FACT_1; break; case "stat_fact2": e.FactorType = EnumFactorType.STAT_FACT_2; break; case "value": e.FactorType = EnumFactorType.VALUE; break; } return e.FactorType; } If I create a Static class(say Constatant) and declare variable like public static string BETA= "beta"; and then if I try to put that in the Case expression like Case Constants.BETA : e.FactorType = EnumFactorType.BETA; break; then the compiler will report error.(quite expected) So is there any other way?(I canot change the switch statement) Using C#3.0 Thanks

    Read the article

  • Populate an Object Model from a data dataTable(C#3.0)

    - by Newbie
    I have a situation I am getting data from some external sources and is populating into the datatable. The data looks like this DATE WEEK FACTOR 3/26/2010 1 RM_GLOBAL_EQUITY 3/26/2010 1 RM_GLOBAL_GROWTH 3/26/2010 2 RM_GLOBAL_VALUE 3/26/2010 2 RM_GLOBAL_SIZE 3/26/2010 2 RM_GLOBAL_MOMENTUM 3/26/2010 3 RM_GLOBAL_HIST_BETA I have a object model like this public class FactorReturn { public int WeekNo { get; set; } public DateTime WeekDate { get; set; } public Dictionary<string, decimal> FactorCollection { get; set; } } As can be seen that the Date field is always constant. And a single(means unique) week can have multiple FACTORS. i.e. For a date(3/26/2010), for Week No. 1, there are two FACTORS(RM_GLOBAL_EQUITY and RM_GLOBAL_GROWTH). Similarly, For a date(3/26/2010), for Week No. 2, there are three FACTORS(RM_GLOBAL_VALUE , RM_GLOBAL_SIZE and RM_GLOBAL_MOMENTUM ). Now we need to populate this data into our object model. The final output will be WeekDate: 3/26/2010 WeekNo : 1 FactorCollection : RM_GLOBAL_EQUITY FactorCollection : RM_GLOBAL_GROWTH WeekNo : 2 FactorCollection : RM_GLOBAL_VALUE FactorCollection : RM_GLOBAL_SIZE FactorCollection : RM_GLOBAL_MOMENTUM WeekNo : 3 FactorCollection : RM_GLOBAL_HIST_BETA That is, overall only 1 single collection, where the Factor type will vary depending on week numbers. I have tried but of useless. Nothing works. Could you please help me?. I feel it is very tough I am using C# 3.0 Thanks

    Read the article

  • Problem in populating a dictionary object using Enumerable.Range() (C#3.0)

    - by Newbie
    If I do for (int i = 0; i < appSettings.Count; i++) { string key = appSettings.Keys[i]; euFileDictionary.Add(key, appSettings[i]); } It is working fine. When I am trying the same thing using Enumerable.Range(0, appSettings.Count).Select(i => { string Key = appSettings.Keys[i]; string Value = appSettings[i]; euFileDictionary.Add(Key, Value); }).ToDictionary<string,string>(); I am getting a compile time error The type arguments for method 'System.Linq.Enumerable.Select(System.Collections.Generic.IEnumerable, System.Func)' cannot be inferred from the usage. Try specifying the type arguments explicitly. Any idea? Using C#3.0 Thanks

    Read the article

< Previous Page | 18 19 20 21 22 23 24 25 26 27 28 29  | Next Page >