Skip to main content

Posts

Showing posts with the label c#

How much to grow buffer in a StringBuilder-like C module?

In C, I'm working on a "class" that manages a byte buffer, allowing arbitrary data to be appended to the end. I'm now looking into automatic resizing as the underlying array fills up using calls to realloc . This should make sense to anyone who's ever used Java or C# StringBuilder . I understand how to go about the resizing. But does anyone have any suggestions, with rationale provided, on how much to grow the buffer with each resize?

Boss says "We need an IPhone app”, What frameworks are similar to Firefox, JQuery, templates, and data linking on an iPhone?

We have a great software foundation based on Microsoft MVC 2, Entity Framework 4, Repositories, POCOs, Service and Control layers, C# Views, JQuery and html. Firefox pulls 100 records in 250 ms, drops it in to a template, links the data to the markup, and we sit back and drink margaritas.

Is there a reason I should not start with C#

I think I'm leaning toward C# and .net as a concentration language for learning web development. I would like to learn good programming fundamentals and I've looked at pretty much everything else. The four I've narrowed it down to have been C#, Python, Ruby and PHP. Is there a reason to stay away from C# (and I don't think the cost issue would really apply to my solo-developer situation but I could be totally wrong). Any thoughts? I realize that these are all great languages so I'm not trying to ask which is the best overall. However, would Ruby be a viable alternative for a first language or does it have too much "magic under the hood" coupled with Rails, and unorthodox methodologies? I do like what I've seen with the language. Source: Tips4all

Add iPhone push notification using ASP.NET server

Here's the overview. I need to add push notification to an iPhone app. Server side is ASP.NET in c#. What I would like is some coaching to work through the process. I will then post generic code for an iPhone project and an ASP.NET web app along with step-by-step instructions so that others can learn. Here is my understanding: Apply for APNS certificate and add it to keychain. (Not sure how to bring this to ASP.NET) Have iPhones register with registerForRemoteNotificationWithTypes, send the value to your server, and store in a DB. Seems like this code to register should be easy but I can't find a good sample. (No problem with sending the value to the ASP.NET server.) Your server app creates a payload string, does JSON encoding, sends to the APNS server for each (or can it be for groups) of iPhones using their device token that was saved into the DB. So to develop the addition, here are the pieces: The iPhone registration code

Method Overloading. Can you overuse it?

What's better practice when defining several methods that return the same shape of data with different filters? Explicit method names or overloaded methods? For example. If I have some Products and I'm pulling from a database explicit way: public List<Product> GetProduct(int productId) { // return a List } public List<Product> GetProductByCategory(Category category) { // return a List } public List<Product> GetProductByName(string Name ) { // return a List } overloaded way: public List<Product> GetProducts() { // return a List of all products } public List<Product> GetProducts(Category category) { // return a List by Category } public List<Product> GetProducts(string searchString ) { // return a List by search string } I realize you may get into a problem with similar signatures , but if you're passing objects instead of base types (string, int, char, DateTime, etc) this will be less of an issue. So... i

Why C# implements methods as non-virtual by default?

Unlike Java, why C# treats methods as non-virtual functions by default? Is it more likely to be a performance issue rather than other possible outcomes? I remind reading a paragraph from Anders Hejlsberg about the several advantages the existing architecture is bringing out. But, what about side effects? Is it really a good trade-off to have non-virtual methods by default?

Why doesn"t Sun do a C# to Java byte code compiler?

We Want to Run Our C# Code on the JVM My company has a large C# code base. Well over half of this code is our core engine for creating, reading, modifying, calculating and writing Excel workbooks. We frequently get questions from customers and potential customers asking whether we are going to build a Java version of our engine - many of them are not at all interested in the UI. We even have a few customers who have taken the trouble to use our .NET library from their Java applications. So, we would like to build a Java version of our core engine, ideally without maintaining a separate Java source code base. Eric Sink described this problem very well. I am in a similar position except for the fact that our software license includes royalty free deployment, making Eric's choice of Mainsoft a nonstarter for us. I have been Googling the likes of "c# to jvm" every few months for several years now with no joy. Having spent ~7 years developing similar software for J

Is it good practice to keep a Lucene IndexWriter & IndexSearcher open for the lifetime of an app

It states in the Lucene documentation that it is fastest to use one instance of an IndexWriter and IndexSearcher across an application. At the moment I have a static instance of IndexWriter open at all times, and a static instance of IndexSearcher that is kept open at all times but rebuilt when if the IndexWriter performs any CRUD operations on the index. I have implemented a Dispose method on my index management class that closes both the IndexWriter and IndexSearcher when the application ends (however it is a web app so this is potentially months of running without being called). Does that sound like reasonable way to go about doing things? And also does using static instances present problems with multi-threading..? I.e. should I be locking my writer and searcher when in use?

IronJs and C# how compile and translate

I'd like to convert my library in Javascript to C#. While doing research, it seems that it'll be easier to compiling the Javascript directly to a .NET executable instead of converting the code to C#. I've found IronJS but I found way to compile to .NET exe or dll to unassemble later.

How to enable navigation buttons of jQuery grid in mvc3 and assign buttons to specific links?

I have read some topic regarding with my question but there code doesn't work for me. Honestly, I'm not good in jQuery. I have this working views and controller, but it has a lot disadvantages that is why I switch to using jQuery grid. Working code (not using jQuery grid): @using Custom.Helpers @model IEnumerable<Models.DeviceMVC> @{ ViewBag.Title = "List"; } <div id="page-title"> <h2>Device list</h2> <div id="Optiontab"> @Html.ActionLink("Create New", "Create") </div> </div> <table id="table-list"> <tr> <th> Branch </th> <th> Name </th> <th> Login id </th> <th> Serial number </th> <th> Brand </th> <th> Model

running Javascript from an external site in C# application

I'm think about building a Silverlight C# Windows phone application for buses in Israel, and I have a basic question(or is it?). The bus site which I want to get the data from uses Javascript. You need to type in the city you want to get to, and it returns the list of stations in that city. I'd like to somehow "get" this page, type the code in, and get the results - all in C#. I'm pretty much lost on where to start from. How do I "get" the site code? how do I run the Javascript action that returns the stations, from within C#? is that even possible?

Disable jquery in masterpage for a specific content page?

I have this code that warns the user about unsaved changes and it's in the MasterPage of the site I'm working on. I have a search page that doesn't allow the user to save anything and it triggers the unsaved changes warning. Is there a way to disable the code for this one content page? var _changesMade = false; $(document).ready(function () { $('form').bind($.browser.msie ? 'propertychange' : 'change', function () { _changesMade = true; }); $(window).bind('beforeunload', function () { if (_changesMade) return 'There are unsaved changes which will be lost if you continue.'; }); });