使用静态或类的应用程序 [英] application that use static or class

查看:59
本文介绍了使用静态或类的应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

什么时候是以下情况下的最佳时间?
1)如果我的应用程序需要频繁加载> 1000张图像,最好的方法是多次按需加载?还是静态会更好?有什么影响?

2)将数据集/数据表存储为在整个应用程序中使用的静态数据吗?或者只是静态连接字符串?如果数据库太小而无法利用SQLLite,将数据集/数据表保持为静态可以证明打开/关闭数据库连接的成本是合理的吗?

推荐答案

为什么需要一次加载所有数千张图像?为什么不根据需要选择每个人呢?我认为您提出的问题不是正确的.您正在尝试寻找一种使用静态类进行证明的方法.但是问题应该是,您需要什么样的方案才能加载所有图像.在任何情况下我都看不到.

如果图像存储在单个位置,并且您有与数据库中特定行关联的图像,则使用该行的ID和图片名称.使用字典可了解需要时要拉出的图像.
Why do you need to load all thousand images at once? Why not take each one on a needed basis? I don't think you are asking the right question. You are trying to seek a way to justify using a static class. But the question should be, what is your scenario that would require you to load all images. I cannot see this in any scenario.

If the images are stored in in a single location and you have an image associated with a particular row in a database, then create a Dictionary using the ID of the row and the name of the image. Use the dictionary to know which image to pull out when you need it.


这篇关于使用静态或类的应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆